【发布时间】:2011-10-04 15:45:49
【问题描述】:
我在滚动视图中创建了一个自定义 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];
【问题讨论】:
-
你传递的帧是否正确??
-
我自己对 iOS 有点陌生,但如果它不是分配/初始化的,你应该释放按钮吗?
-
太棒了 :)) 这就是问题所在,当我释放它时它没有显示出来。我首先使用带有框架的 alloc 创建它......后来替换了它。谢谢问题解决了
标签: iphone image uibutton scrollview