Created
June 29, 2016 09:10
-
-
Save SixBe/9e10d0ef8e63ac5b0dbf6915a8525f7e to your computer and use it in GitHub Desktop.
Class for a Ball view
This file contains 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
public class Ball: UIView { | |
public init(radius: CGFloat) { | |
super.init(frame: CGRect(origin: .zero, size: CGSize(width: radius * 2, height: radius * 2))) | |
self.layer.cornerRadius = radius | |
self.backgroundColor = .red() | |
let indicator = UIView(frame: .zero) | |
self.addSubview(indicator) | |
indicator.backgroundColor = .white() | |
indicator.frame.size = CGSize(width: 20, height: 10) | |
indicator.frame.origin = CGPoint(x: self.bounds.maxX - 20, y: self.bounds.midY - 5) | |
} | |
required public init?(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
public func rotate(angle: CGFloat) { | |
self.transform = self.transform.rotate(angle) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Medium article