gpt4 book ai didi

ios - 以编程方式设置 RoundedRect 按钮

转载 作者:行者123 更新时间:2023-11-28 22:02:42 26 4
gpt4 key购买 nike

我尝试使用以下设置圆形按钮,但它从 View 中消失了。如果我删除了

takebtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

然后显示矩形按钮。帮助我获取 RoundedRect 按钮。

 takebtn = [[UIButton alloc]initWithFrame:CGRectMake(30, 325, 250, 40)];
takebtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[takebtn setTitle:@"Take Photo" forState:UIControlStateNormal];
takebtn.backgroundColor=[UIColor colorWithRed:50.0/255.0 green:205.0/255.0 blue:50.0/255.0 alpha:1.0];
[takebtn addTarget:self
action:@selector(takePhoto:)
forControlEvents:(UIControlEvents)UIControlEventTouchDown];
[nextview addSubview:takebtn];

最佳答案

您需要像下面这样修改您的代码:-

takeBtn.layer.cornerRadius = 10; //value can be change accordingly.
takeBtn.clipsToBounds = YES;

注意:- ios7 中无需导入 Quartz 框架

关于ios - 以编程方式设置 RoundedRect 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24721475/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com