ios UIButton部分圆角

查看:296
本文介绍了ios UIButton部分圆角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

我用的是Masonry布局.
我想绘制如箭头所示的部分圆角按钮.请问用代码怎么实现?

在哪个方法里面写?

code:

//部分圆角按钮
    UIButton *loggedBtn = [[UIButton alloc]init];
    loggedBtn.backgroundColor = [UIColor blueColor];
    
    [headView addSubview:loggedBtn];
    [loggedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(40);
        make.height.offset(20);
        make.right.equalTo(headView);
        make.centerY.equalTo(headView);
    }];

解决方案

 //部分圆角按钮
    UIButton *loggedBtn = [[UIButton alloc]init];
    loggedBtn.backgroundColor = [UIColor blueColor];
    loggedBtn.layer.cornerRadius = 10;

    UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10);

    [self.view addSubview:loggedBtn];
    [loggedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(80);
        make.height.offset(20);
        make.right.equalTo(self.view.mas_right).with.offset(padding.right);
        make.centerY.equalTo(self.view);
    }];

这篇关于ios UIButton部分圆角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆