Skip to content

Instantly share code, notes, and snippets.

@SixBe
Created June 29, 2016 09:10
Show Gist options
  • Save SixBe/9e10d0ef8e63ac5b0dbf6915a8525f7e to your computer and use it in GitHub Desktop.
Save SixBe/9e10d0ef8e63ac5b0dbf6915a8525f7e to your computer and use it in GitHub Desktop.
Class for a Ball view
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)
}
}
@SixBe
Copy link
Author

SixBe commented Jul 13, 2016

Medium article

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment