iOS设置控件不同方位的圆角(OC & Swift)

热门标签

,

特别声明:文章多为网络转载,资源使用一般不提供任何帮助,特殊资源除外,如有侵权请联系!

前言:

设置控件的圆角,包括有:

没有圆角,全部圆角,上部圆角,下部圆角,左部圆角,右部圆角,左上圆角,右上圆角,左下圆角,左下圆角

OC代码

NSArray *titleArr = @[@"没有圆角",@"全部圆角",@"上部圆角",@"下部圆角",@"左部圆角",@"右部圆角",@"左上圆角",@"右上圆角",@"左下圆角",@"左下圆角"];
    CGFloat space = 10;
    NSInteger lineCount = 4;
    CGFloat view_WID = (ScreenWidth - space * (lineCount + 1))/lineCount;
    for (int i = 0; i<10; i++) {
        UILabel *textLab = [[UILabel alloc]init];
        textLab.textAlignment = NSTextAlignmentCenter;
        textLab.textColor = [UIColor redColor];
        textLab.backgroundColor = [UIColor lightGrayColor];
        textLab.frame = CGRectMake(space + (view_WID + space)*(i%lineCount), 100 + (view_WID + space)*(i/lineCount), view_WID, view_WID);
        textLab.text = titleArr[i];
        [textLab setZFJGlobalViewWith:i cornerRadius:10.0];
        [self.view addSubview:textLab];
    }

Swift代码

let titleArr = ["没有圆角","全部圆角","上部圆角","下部圆角","左部圆角","右部圆角","左上圆角","右上圆角","左下圆角","左下圆角"]
        let space : Float = 10.0
        let lineCount = 4
        let view_WID : Float = (ScreenWidth - space * (Float(lineCount) + 1))/Float(lineCount)
        
        for i in stride(from: 0, to: 10, by: 1) {
            print("\(i)")
            let textLab = UILabel()
            textLab.textAlignment = NSTextAlignment.center
            textLab.textColor = UIColor.red
            textLab.backgroundColor = UIColor.lightGray
            let rect = CGRect(x: CGFloat(space + (view_WID + space)*Float(i%lineCount)), y: CGFloat(100 + (view_WID + space)*Float(i/lineCount)), width: CGFloat(view_WID), height: CGFloat(view_WID))
            textLab.frame = rect
            textLab.text = titleArr[i]
            textLab .setZFJGlobalView(viewType: GlobalViewType(rawValue: i)!, cornerRadius: 10.0)
            self.view.addSubview(textLab)
        }

 

标签:

未经允许不得转载:作者:SheaYang, 转载或复制请以 超链接形式 并注明出处 技术Dog|博客
原文地址:《iOS设置控件不同方位的圆角(OC & Swift)》 发布于2019-11-03

分享到:
赞(0) 打赏

评论 抢沙发

4 + 9 =


iOS设置控件不同方位的圆角(OC & Swift)

长按图片转发给朋友

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

Vieu4.0主题
专业打造轻量级个人企业风格博客主题!专注于前端开发,全站响应式布局自适应模板。

登录

忘记密码 ?