Created
January 17, 2019 13:38
-
-
Save Aymenworks/c7131a4a74e8caa872c85d50182f13f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Colors { | |
static let backgroundButtonBackgroundColor = UIColor.clear | |
static let backgroundButtonTintColor = #colorLiteral(red: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1) | |
static let foregroundButtonBackgroundColor = #colorLiteral(red: 1, green: 0.8, blue: 0, alpha: 1) | |
static let foregroundButtonTintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) | |
} | |
let shapeLayer = CAShapeLayer() | |
let backgroundButton = UIButton() | |
let foregroundButton = UIButton() | |
func setup() { | |
UI: do { | |
backgroundButton.setImage(UIImage(named: "search"), for: .normal) | |
backgroundButton.backgroundColor = Colors.backgroundButtonBackgroundColor | |
backgroundButton.tintColor = Colors.backgroundButtonTintColor | |
foregroundButton.setImage(UIImage(named: "search"), for: .normal) | |
foregroundButton.backgroundColor = Colors.foregroundButtonBackgroundColor | |
foregroundButton.tintColor = Colors.foregroundButtonTintColor | |
} | |
layers: do { | |
// the shape layer ( mask ) will hide/show the foreground button depending on the scroll animation progress | |
foregroundButton.layer.mask = shapeLayer | |
foregroundButton.layer.masksToBounds = true | |
} | |
layout: do { | |
addSubview(backgroundButton) | |
addSubview(foregroundButton) | |
// layout buttons using autolayout there | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment