【发布时间】:2011-11-29 19:41:15
【问题描述】:
我正在以编程方式为 iPad 应用程序创建一个按钮。当我看到按钮时,它下方似乎有一个阴影类型的东西。它是什么,我怎样才能摆脱它?
这是创建它的代码:
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.titleLabel.font = [UIFont fontWithName:@"Trebuchet MS" size:12];
[myButton setTitle:@"test" forState:UIControlStateNormal];
myButton.frame = CGRectMake(0, 0, self.leftScrollView.frame.size.width, 50);
UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gear12.png"]];
[myButton addSubview:myImageView];
[self.leftScrollView addSubview:myButton];
更新:
好的,我注意到只有当它在我的滚动视图中时才会产生这种效果。如果我将它添加到视图中,则没有阴影效果。
顶部测试按钮,该按钮是视图的子视图。底部按钮是滚动视图的子视图,它是视图的子视图(按钮/视图与按钮/滚动视图/视图)。
白色部分是视图,灰色部分是滚动视图/视图。
更新 2:
正如 robmayor 所指出的,UIButtons 总是具有双线效果,只是在背景颜色为白色时不明显。蓝色是视图,灰色是子视图滚动视图。
【问题讨论】:
标签: iphone objective-c ios