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

bug fix. #2

Merged
merged 1 commit into from
Dec 30, 2015
Merged
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
2 changes: 1 addition & 1 deletion KYNavigationProgress/ProgressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal final class ProgressView: UIView {

private let barWidthConstraint: NSLayoutConstraint

override var bounds: CGRect {
override var frame: CGRect {
didSet {
let tmpProgress = progress
progress = tmpProgress
Expand Down
36 changes: 6 additions & 30 deletions KYNavigationProgress/UINavigationController+Progress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@ public extension UINavigationController {
Default is 2.0
*/
public var progressHeight: CGFloat {
get {
return navigationBar.constraints
.filter{ $0.identifier == constraintIdentifier }
.first?.constant ?? 0.2
}
get { return progressView.frame.height }
set {
navigationBar.constraints
.filter{ $0.identifier == constraintIdentifier }
.first?.constant = newValue
progressView.frame.origin.y = navigationBar.frame.height - newValue
progressView.frame.size.height = newValue
}
}

Expand Down Expand Up @@ -76,31 +71,12 @@ public extension UINavigationController {
)
let progressView = ProgressView(frame: frame)

progressView.translatesAutoresizingMaskIntoConstraints = false

navigationBar.addSubview(progressView)

let progressHeightConstraint = NSLayoutConstraint(
item: progressView,
attribute: .Height,
relatedBy: .Equal,
toItem: nil,
attribute: .NotAnAttribute,
multiplier: 1,
constant: defaultHeight)
progressHeightConstraint.identifier = constraintIdentifier
progressView.autoresizingMask = [
.FlexibleWidth, .FlexibleTopMargin
]

navigationBar.addConstraint(progressHeightConstraint)
navigationBar.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat(
"H:|-0-[progressView]-0-|",
options: [],
metrics: nil,
views: ["progressView" : progressView]))
navigationBar.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat(
"V:[progressView]-0-|",
options: [],
metrics: nil,
views: ["progressView" : progressView]))

return progressView
}
Expand Down
1 change: 1 addition & 0 deletions Sample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
navigationController?.progressHeight = 30
}

override func didReceiveMemoryWarning() {
Expand Down