Skip to content

Instantly share code, notes, and snippets.

@codetalks-new
Created January 5, 2015 01:45
Show Gist options
  • Save codetalks-new/4ccb4c7cf12533bec0e6 to your computer and use it in GitHub Desktop.
Save codetalks-new/4ccb4c7cf12533bec0e6 to your computer and use it in GitHub Desktop.
CircleImageView
import UIKit
class CircleImageView: UIImageView {
var borderWidth:CGFloat=6.0{
didSet{
updateBorderStyle()
}
}
var borderColor:UIColor=UIColor(white: 160, alpha: 0.5){
didSet{
updateBorderStyle()
}
}
override init(image: UIImage!) {
super.init(image: image)
commonInit()
}
override init(image: UIImage!, highlightedImage: UIImage?) {
super.init(image: image, highlightedImage: highlightedImage)
commonInit()
}
override init() {
super.init()
commonInit()
}
func commonInit(){
println("commonInit")
layer.cornerRadius = frame.size.width * 0.5
clipsToBounds = true
updateBorderStyle()
}
func updateBorderStyle(){
layer.borderWidth = borderWidth
layer.borderColor = borderColor.CGColor
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment