我是一个Objective C的新手。我如何将这个按钮的背景设置为一个图像(图像已经在XCode的资源文件夹中,“blue_button.png”)而不是clearColor?此外,我宁愿我使用图像作为按钮的形状,而不是UIButtonTypeRoundedRect。为UIButton设置一个背景图像
btnClear = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
btnClear.frame = CGRectMake(115, 350, 90, 40);
[btnClear setTitle:@"Clear" forState:UIControlStateNormal];
btnClear.backgroundColor = [UIColor clearColor];
[btnClear addTarget:self action:@selector(clearAction:)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnClear];
我知道如何在Interface Builder中做到这一点,但我宁愿了解如何在XCode中做到这一点。
你可以做,在Interface Builder如果你使用笔尖 – Vjy 2011-01-05 19:42:51
你应该接受一个答案,这是对所有参与者都有好处...... – whyoz 2016-07-11 10:21:16