diff --git a/Yep/Show.storyboard b/Yep/Show.storyboard index 7039306b..9e69c1a1 100644 --- a/Yep/Show.storyboard +++ b/Yep/Show.storyboard @@ -26,9 +26,9 @@ - + - + diff --git a/Yep/ViewControllers/Show/ShowViewController.swift b/Yep/ViewControllers/Show/ShowViewController.swift index e4a5946a..0ccea62f 100644 --- a/Yep/ViewControllers/Show/ShowViewController.swift +++ b/Yep/ViewControllers/Show/ShowViewController.swift @@ -25,6 +25,8 @@ class ShowViewController: UIViewController { super.viewDidLoad() finishButton.tintColor = UIColor.yepTintColor() + finishButton.needShowAccessory = true + pageControlBottomConstraint.constant = Ruler.match(.iPhoneHeights(0, 10, 20, 30)) finishButtonBottomConstraint.constant = Ruler.match(.iPhoneHeights(20, 30, 40, 50)) diff --git a/Yep/Views/Buttons/BorderButton.swift b/Yep/Views/Buttons/BorderButton.swift index 2023e603..fcdd3466 100644 --- a/Yep/Views/Buttons/BorderButton.swift +++ b/Yep/Views/Buttons/BorderButton.swift @@ -15,6 +15,23 @@ class BorderButton: UIButton { @IBInspectable var borderColor: UIColor = UIColor.yepTintColor() @IBInspectable var borderWidth: CGFloat = 1 + var needShowAccessory: Bool = false { + willSet { + if newValue != needShowAccessory { + if newValue { + showAccessory() + } else { + accessoryImageView.removeFromSuperview() + } + } + } + } + + lazy var accessoryImageView: UIImageView = { + let imageView = UIImageView(image: UIImage(named: "icon_accessory_mini")) + return imageView + }() + override func didMoveToSuperview() { super.didMoveToSuperview() @@ -23,4 +40,17 @@ class BorderButton: UIButton { layer.borderWidth = borderWidth } + func showAccessory() { + + accessoryImageView.tintColor = borderColor + + addSubview(accessoryImageView) + accessoryImageView.setTranslatesAutoresizingMaskIntoConstraints(false) + + let accessoryImageViewTrailing = NSLayoutConstraint(item: accessoryImageView, attribute: .Trailing, relatedBy: .Equal, toItem: self, attribute: .Trailing, multiplier: 1, constant: -10) + let accessoryImageViewCenterY = NSLayoutConstraint(item: accessoryImageView, attribute: .CenterY, relatedBy: .Equal, toItem: self, attribute: .CenterY, multiplier: 1, constant: 0) + + NSLayoutConstraint.activateConstraints([accessoryImageViewTrailing, accessoryImageViewCenterY]) + } + }