知识点

作者: BeethOven | 来源:发表于2018-08-05 16:58 被阅读10次
    1. 利用UIBezierPath和CAShapeLayer生成任意位置圆角
      设置view左上和右上圆角半径为20
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100, 200, 200, 200)];
        view.backgroundColor = [UIColor redColor];
        UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
        CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
        maskLayer.frame = view.bounds;
        maskLayer.path = bezierPath.CGPath;
        view.layer.mask = maskLayer;
        
        [self.view addSubview:view];
    

    2.label大小固定 内容根据大小自适应字体

    //初始值 为10,设置minimumScaleFactor=0.5,就代表最小字体为5。adjustsFontSizeToFitWidth属性默认是NO,需要设置YES。
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 150, 15)];
    label = @"label大小固定 内容根据大小自适应字体";
    label = [UIFont systemFontOfSize:10];
    label = YES;
    label =0.5;
    

    相关文章

      网友评论

          本文标题:知识点

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