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

Add cornerRadius value on UnderlineFocusView #120

Merged
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
26 changes: 18 additions & 8 deletions PagingKit/Menu Cells/Underline/UnderlineFocusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class UnderlineFocusView: UIView {
underlineView.backgroundColor = underlineColor
}
}

/// The color of underline
public var underlineHeight = CGFloat(4) {
didSet {
Expand All @@ -45,15 +45,25 @@ public class UnderlineFocusView: UIView {

public var underlineWidth: CGFloat? = nil {
didSet {
if let underlineWidth = underlineWidth {
widthConstraint.isActive = true
widthConstraint.constant = underlineWidth
} else {
widthConstraint.isActive = false
}
if let underlineWidth = underlineWidth {
widthConstraint.isActive = true
widthConstraint.constant = underlineWidth
} else {
widthConstraint.isActive = false
}
}
}

public var masksToBounds: Bool {
get { return underlineView.layer.masksToBounds }
set { underlineView.layer.masksToBounds = newValue }
}

public var cornerRadius: CGFloat {
get { return underlineView.layer.cornerRadius }
set { underlineView.layer.cornerRadius = newValue }
}

private let widthConstraint: NSLayoutConstraint
private let heightConstraint: NSLayoutConstraint
private let underlineView = UIView()
Expand Down Expand Up @@ -97,7 +107,7 @@ public class UnderlineFocusView: UIView {
super.init(frame: frame)
setup()
}

private func setup() {
addSubview(underlineView)
underlineView.translatesAutoresizingMaskIntoConstraints = false
Expand Down