Last active
December 30, 2015 09:29
-
-
Save ginrou/7809580 to your computer and use it in GitHub Desktop.
UIImageViewを円形にマスクをかける
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
#import <UIKit/UIKit.h> | |
@interface UIImageView (CircleMask) | |
- (void)circleMask; | |
- (void)circleMaskBorderWitdh:(CGFloat)width color:(CGColorRef)color; | |
@end |
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
@import QuartzCore; | |
#import "UIImageView+CircleMask.h" | |
@implementation UIImageView (CircleMask) | |
- (void)circleMask { | |
CALayer *layer = self.layer; | |
layer.cornerRadius = MAX(self.frame.size.width, self.frame.size.height) / 2.0; | |
layer.masksToBounds = YES; | |
} | |
- (void)circleMaskBorderWitdh:(CGFloat)width color:(CGColorRef)color { | |
[self circleMask]; | |
self.layer.borderWidth = width; | |
self.layer.borderColor = color; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to use
import header file
set mask as
or with radius and color