Skip to content

Instantly share code, notes, and snippets.

@stleamist
Last active May 19, 2020 11:10
Show Gist options
  • Save stleamist/47045399ebede9c8a71996e4799cc3f4 to your computer and use it in GitHub Desktop.
Save stleamist/47045399ebede9c8a71996e4799cc3f4 to your computer and use it in GitHub Desktop.
A replication of download button in the App Store.
import UIKit
class OfferButton: UIButton {
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
private func setup() {
self.layer.cornerRadius = 14
self.layer.masksToBounds = true
self.setTitleColor(self.tintColor, for: .normal)
self.titleLabel?.font = .systemFont(ofSize: 15, weight: .bold)
self.setBackgroundColor(.tertiarySystemGroupedBackground, for: .normal)
}
override var intrinsicContentSize: CGSize {
return CGSize(width: 72, height: 28)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment