ios - 自定义 UIButton iOS 应用程序

标签 ios uibutton

我正在开发一个 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/

相关文章:

ios - Cordova Launch Storyboard图像未结转

ios - 可以在 Xcode Simulator 中进行直接但独立的 View Controller UI 测试吗?

ios - GoogleMaps for iOS infoWindow 与来自实体的数据进行搜索

ios - Swift 4 - 添加到 UINavigationBar 时无法控制 UIButton 大小

ios - 动态 Tableviewcell 中的按钮不可点击

ios - Instagram 的缩放是如何工作的?

ios - 数据被覆盖 : Core Data

ios - 使用自定义类以编程方式创建 UIButton

ios - iOS UIButton 背景边框问题

ios - 为 TableViewCell 创建一个 UI 按钮