Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- @IBDesignable class EthereumCoinView: UIView {
- @IBInspectable var lineColor: UIColor = UIColor.yellow {
- didSet {
- setNeedsDisplay()
- }
- }
- @IBInspectable var coinColor: UIColor = UIColor.white {
- didSet {
- setNeedsDisplay()
- }
- }
- //MARK: - Initializers
- init() {
- super.init(frame: .zero)
- setup()
- }
- override init(frame: CGRect) {
- super.init(frame: frame)
- setup()
- }
- override func awakeFromNib() {
- super.awakeFromNib()
- setup()
- }
- required init?(coder aDecoder: NSCoder) {
- super.init(coder: aDecoder)
- setup()
- }
- //MARK: - Convenience Initializers
- convenience init(frame: CGRect, coinColor: UIColor, lineColor: UIColor) {
- self.init(frame: frame)
- self.coinColor = coinColor
- self.lineColor = lineColor
- setup()
- }
- convenience init(origin: CGPoint, size: CGSize, coinColor: UIColor, lineColor: UIColor) {
- self.init(frame: CGRect(origin: origin, size: size))
- self.coinColor = coinColor
- self.lineColor = lineColor
- setup()
- }
- //MARK: - Custom
- func setup() {
- // add custom code here
- isOpaque = false
- }
- //MARK: - Drawing Code
- override func draw(_ rect: CGRect) {
- CryptoStyleKit.drawEthereumcoin3(frame: rect, lineColor: lineColor, coinColor: coinColor)
- }
- }
Add Comment
Please, Sign In to add comment