Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix an underline padding showing error #115

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sources/Classes/SwipeMenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public struct SwipeMenuViewOptions {

/// ItemView font. Defaults to `14 pt as bold SystemFont`.
public var font: UIFont = UIFont.boldSystemFont(ofSize: 14)

/// ItemView selected font. Defaults to `14 pt as bold SystemFont`.
public var selectedFont: UIFont = UIFont.boldSystemFont(ofSize: 14)

/// ItemView clipsToBounds. Defaults to `true`.
public var clipsToBounds: Bool = true
Expand Down
7 changes: 6 additions & 1 deletion Sources/Classes/TabItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ final class TabItemView: UIView {

public var textColor: UIColor = UIColor(red: 140/255, green: 140/255, blue: 140/255, alpha: 1.0)
public var selectedTextColor: UIColor = .white
public var selectedFont: UIFont = UIFont.boldSystemFont(ofSize: 14)
public var font: UIFont = UIFont.boldSystemFont(ofSize: 14)


public var isSelected: Bool = false {
didSet {
if isSelected {
titleLabel.textColor = selectedTextColor
titleLabel.font = selectedFont
} else {
titleLabel.textColor = textColor
titleLabel.font = font
}
}
}
Expand All @@ -34,7 +39,7 @@ final class TabItemView: UIView {
private func setupLabel() {
titleLabel = UILabel(frame: bounds)
titleLabel.textAlignment = .center
titleLabel.font = UIFont.boldSystemFont(ofSize: 14)
titleLabel.font = font
titleLabel.textColor = UIColor(red: 140/255, green: 140/255, blue: 140/255, alpha: 1.0)
titleLabel.backgroundColor = UIColor.clear
addSubview(titleLabel)
Expand Down
14 changes: 11 additions & 3 deletions Sources/Classes/TabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ open class TabView: UIScrollView {
tabItemView.titleLabel.font = options.itemView.font
tabItemView.textColor = options.itemView.textColor
tabItemView.selectedTextColor = options.itemView.selectedTextColor
tabItemView.selectedFont = options.itemView.selectedFont
}

tabItemView.isSelected = index == currentIndex
Expand Down Expand Up @@ -422,9 +423,16 @@ extension TabView {
} else {
adjustCellWidth = (frame.width - options.margin * 2) / CGFloat(dataSource.numberOfItems(in: self)) - options.additionView.padding.horizontal
}

additionView.frame.origin.x = adjustCellWidth * CGFloat(index) - options.additionView.padding.left
additionView.frame.size.width = adjustCellWidth

if options.addition == .underline {
let itemWidth = adjustCellWidth + options.additionView.padding.horizontal
let startX = (itemWidth * CGFloat(index))
additionView.frame.origin.x = startX + options.additionView.padding.left
additionView.frame.size.width = adjustCellWidth
} else {
additionView.frame.origin.x = adjustCellWidth * CGFloat(index) - options.additionView.padding.left
additionView.frame.size.width = adjustCellWidth
}
}

fileprivate func animateAdditionView(index: Int, animated: Bool, completion: ((Bool) -> Swift.Void)? = nil) {
Expand Down