知识点

2018-08-05  本文已影响10人  BeethOven
  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;
上一篇下一篇

猜你喜欢

热点阅读