-
-
Save Matheus193dn/80a90f288578780c3cb6e06431dc21ce to your computer and use it in GitHub Desktop.
Circular Image View UIImageView Subclass
This file contains hidden or 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