iphone - ios5:删除UIButton边框

标签 iphone objective-c xcode xcode4 ios5

我的应用程序放置了一个带有自定义背景图像的按钮,我不需要在它周围添加边框。 我不确定如何删除边框。 我的代码是:

  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/

相关文章:

IOS7,8,9 接收之前的推送通知行为

iphone - UIActivity 指示器用作 Uitableview 页脚时在设备中显示拉伸(stretch)?

objective-c - iOS 应用程序中 iTunes 音乐商店的音乐预览

iphone - 我可以在 Apple Power PC G5 上下载并运行 XCode 和 Apple iOS 4.1 吗?

ios - 不同 View Controller 上的重复按钮操作?

ios - 具有垂直滚动功能的 View 内部的 UICollectionView 和 ScrollView

iphone - 查询AppStore?

iphone - 如何更改 map 套件 View 中注释的图钉颜色

ios - NSIndexPath 是否仅用于初始化要在 UITableView 实例中使用的对象?

iphone - 如何使用 NSArray 中存储的位置数据创建图像和标签