我的应用程序放置了一个带有自定义背景图像的按钮,我不需要在它周围添加边框。 我不确定如何删除边框。 我的代码是:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame=CGRectMake(100, 170, 100,30);
UIImage *cbutton = [UIImage imageNamed:@"pdficon_small.png"];
[button setImage:cbutton forState:UIControlStateNormal];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button2 addTarget:self
action:@selector(openWordings:)
forControlEvents:UIControlEventTouchDown];
[button setTag:2];
[self.view addSubview:button];
提前致谢。
最佳答案
我假设您的意思是 button
周围有一个边框。
要删除它,请替换行
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
有了这个
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
您现在正在做的是创建一个标准的 RoundedRect 按钮,然后在顶部放置一个图像。
使用 UIButtonTypeCustom
将创建本质上是“空白”按钮的内容,允许您使用您的图像。
关于iphone - ios5:删除UIButton边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9067721/