ios5:删除UIButton边框

use*_*067 9 iphone xcode objective-c 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];
Run Code Online (Sandbox Code Playgroud)

提前致谢.

Ami*_*hah 14

我假设你的意思是有一个边界button.要删除它,请更换线路

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
Run Code Online (Sandbox Code Playgroud)

有了这个

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
Run Code Online (Sandbox Code Playgroud)

你现在正在做的是创建一个标准的RoundedRect按钮,然后将图像放在顶部.使用UIButtonTypeCustom将创建本质上是"空白"按钮,允许您使用您的图像.