mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-16 16:28:45 +10:00
add accessoryImageView for BorderButton
This commit is contained in:
+2
-2
@@ -26,9 +26,9 @@
|
||||
<rect key="frame" x="168" y="570" width="39" height="37"/>
|
||||
</pageControl>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="c1Z-F1-RQr" customClass="BorderButton" customModule="Yep" customModuleProvider="target">
|
||||
<rect key="frame" x="134" y="607" width="107" height="40"/>
|
||||
<rect key="frame" x="124" y="607" width="127" height="40"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<inset key="contentEdgeInsets" minX="20" minY="10" maxX="20" maxY="10"/>
|
||||
<inset key="contentEdgeInsets" minX="30" minY="10" maxX="30" maxY="10"/>
|
||||
<state key="normal" title="Start Yep">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user