IOS开发知识点记录

  1. base64编码转UIImage对象
NSURL *url = [NSURL URLWithString:imageString];
NSData *imageData = [NSData dataWithContentsOfURL:url];
// 将NSData转为UIImage
UIImage *decodedImage = [UIImage imageWithData: imageData];
  • 给view增加圆角
- (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];
  • 图片设置tintColor
UIImageView *imageView = ...
UIImage *image = [UIImage imageNamed:@"imageName"];
imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
imageView.tintColor = [UIColor colorWithHex:0xffffff];

你可能感兴趣的:(IOS开发知识点记录)