1
我在滾動視圖內創建了一個自定義UIButton。 但圖片不顯示,有什麼想法我做錯了什麼?iphone自定義UIButton不顯示圖片
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:[UIImage imageNamed:@"anzahl.png"] forState:UIControlStateNormal];
[button setTitle:@"-" forState:UIControlStateNormal];
button.frame = CGRectMake(x, y, viewWidth, viewHeight);//width and height should be same value
button.clipsToBounds = YES;
button.layer.cornerRadius = 20;//half of the width
button.layer.borderColor=[UIColor blueColor].CGColor;
button.layer.borderWidth=1.0f;
[button setAlpha:1.0];
[scroller1 addSubview:button];
[button release];
你傳遞了正確的幀? – Hisenberg
我自己對iOS有點新,但是如果它不是alloc/init-ed,你應該釋放按鈕嗎? – Gregir
偉大的:))這是問題,當我釋放它沒有顯示。我首先用alloc創建了它,後來將其替換。謝謝問題解決 – Ferdi