Skip to content

Instantly share code, notes, and snippets.

@bishalg
Created May 18, 2016 14:10
Show Gist options
  • Save bishalg/c9604c729a469c20bb4b782035901417 to your computer and use it in GitHub Desktop.
Save bishalg/c9604c729a469c20bb4b782035901417 to your computer and use it in GitHub Desktop.
Circular Image View UIImageView Subclass
// Created by Bishal Ghimire on 5/15/16.
import UIKit
@IBDesignable
class CircularImageView: UIImageView {
override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
makeCircularImage()
}
// drawRect will not work on UIImageView
override func layoutSubviews() {
super.layoutSubviews()
makeCircularImage()
}
func makeCircularImage() {
self.layer.cornerRadius = self.frame.size.height / 2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment