Created
May 18, 2016 14:10
-
-
Save bishalg/c9604c729a469c20bb4b782035901417 to your computer and use it in GitHub Desktop.
Circular Image View UIImageView Subclass
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
// 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