我是一個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