- base64编码转UIImage对象
NSURL *url = [NSURL URLWithString:imageString];
NSData *imageData = [NSData dataWithContentsOfURL:url];
// 将NSData转为UIImage
UIImage *decodedImage = [UIImage imageWithData: imageData];
- (void)setCornerRect:(UIRectCorner)corners radius:(CGFloat)cornerRadius {
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.width, self.height)
byRoundingCorners:corners
cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = CGRectMake(0, 0, self.width, self.height);
maskLayer.path = maskPath.CGPath;
self.layer.mask = maskLayer;
}
----使用范例----
UIView *view = ...
[view setCornerRect:UIRectCornerTopLeft | UIRectCornerTopRight radius:12];
UIImageView *imageView = ...
UIImage *image = [UIImage imageNamed:@"imageName"];
imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
imageView.tintColor = [UIColor colorWithHex:0xffffff];