我是Objective C的新手。如何将此按钮的背景设置为图像(图像已经在XCode的资源文件夹中,名称为“blue_button.png”),而不是透明的?另外,我希望使用该图像作为按钮的形状,而不是使用UIButtonTypeRoundedRect。
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中实现。