3
我以前有過這個問題,但能夠解決它到現在爲止,基本上我創建一個自定義的UIbutton設置它的圖像作爲一個uiimage,然後有一個標籤的按鈕,直到我實現下面的代碼現在失去它的標籤。我需要這個標籤,因爲它在後面的代碼中以編程方式設置。爲什麼我在按鈕中放置圖像時,UIButton.titleLabel.text會消失?
NSString *imageName = [NSString stringWithFormat:kNameOfButtonimage ];
UIImage *image = [UIImage imageNamed:imageName];
[button setImage:image forState:UIControlStateNormal ];
任何幫助你可以借出將mucho讚賞。
-nick
我發現同樣適用於titleColor也即此 '[buttonTemp setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];' 而不是: 'buttonTemp.titleLabel.textColor = [UIColor blackColor];' – Ted 2012-10-26 11:53:02