Skip to content

Commit

Permalink
Merge pull request #2 from ykyouhei/develop
Browse files Browse the repository at this point in the history
bug fix.
  • Loading branch information
ykyouhei committed Dec 30, 2015
2 parents fb10c6f + bc2ed6f commit 12280f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 31 deletions.
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

0 comments on commit 12280f0

Please sign in to comment.