gpt4 book ai didi

ios - 自定义 UIButton iOS 应用程序

转载 作者:行者123 更新时间:2023-11-28 20:10:08 25 4
gpt4 key购买 nike

我正在开发一个 iOS 应用程序,我必须插入一个 UIButton。

我想自定义这个按钮,我想要一个这样的按钮:

enter image description here

我的代码是这样的,但我无法制作圆角:

_topImagesScrollViewButton = [UIButton buttonWithType:UIButtonTypeCustom];
_topImagesScrollViewButton.frame = CGRectMake(screenWidth/2-25, topBarHeight+paddHeight, 37 , 37);
_topImagesScrollViewButton.backgroundColor = [UIColor colorWithRed:red_middle green:green_middle blue:blue_middle alpha:alpha_middle];
[_topImagesScrollViewButton setTitle:@"Top" forState:UIControlStateNormal];
[_topImagesScrollViewButton setTitleColor:[UIColor colorWithRed:red_text green:green_text blue:blue_text alpha:alpha_text] forState:UIControlStateNormal];forState:UIControlStateNormal];
[_topImagesScrollViewButton addTarget:self action:@selector(topImagesScrollVieButtonTapped) forControlEvents:UIControlEventTouchUpInside];

我该怎么办?

最佳答案

我会使用上面的图像来设置按钮的图像,而不是绘制形状:

[_topImagesScrollViewButton setImage:@"yourimagename.png" forState:UIControlStateNormal];

关于ios - 自定义 UIButton iOS 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20614869/

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