美文网首页
IOS开发知识点记录

IOS开发知识点记录

作者: Sivin | 来源:发表于2021-03-21 17:32 被阅读0次
    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开发知识点记录

          本文链接:https://www.haomeiwen.com/subject/bscocltx.html