我正在开发一个 iOS 应用程序,我必须插入一个 UIButton。
我想自定义这个按钮,我想要一个这样的按钮:
我的代码是这样的,但我无法制作圆角:
_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/