【发布时间】:2014-06-28 03:52:13
【问题描述】:
这个被我扔了,我想知道是否有人可以帮忙。我正在尝试在我选择的 UITableViewCell 上显示阴影,它在模拟器上运行良好,但在运行 iOS 7.0.4 的 iPad 3rd Gen 上却不行
我有一个子类 UITableViewCell,它正在分配/初始化一个子类 UIView 作为其 selectedBackground。除了没有显示在设备上之外,一切正常。
在我的子类 UITableViewCell...
- (void)awakeFromNib
{
self.selectedBackgroundView = [[OTHD_CellSelectedView alloc] initWithFrame:self.bounds];
}
在我的 OTHD_CellSelectedView...
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self createLayer];
}
return self;
}
- (void) createLayer
{
CALayer *the_layer = [CALayer layer];
[self.layer insertSublayer:the_layer atIndex:0];
the_layer.frame = self.bounds;
the_layer.backgroundColor = [[UIColor whiteColor] CGColor];
the_layer.shadowColor = [UIColor blackColor].CGColor;
the_layer.shadowOffset = CGSizeMake(0, 0);
the_layer.shadowRadius = 10.0;
the_layer.shadowOpacity = 0.7;
}
【问题讨论】:
-
作为实验,尝试将 CALayer *the_layer 声明为属性,并使其成为强引用。有什么改变吗?
-
您在其他设备上尝试过吗?可能是视网膜第三代 iPad 上的图形无法支持某些视觉效果。模拟器通常是 UI 效率和支持的危险指南,因为它将使用 Mac 的全部资源来完成它。
-
@Tander,感谢您的建议,但不,这不会改变任何事情。
-
@Cocoadelica,这可能会在另一台设备上工作,但它对 CALayer 的使用相当少,我确实需要支持所有运行 iOS7 的 iPad。
-
你在后来的设备上试过了吗? iPhone 4S / iPhone 5s?
标签: objective-c ipad ios7 uitableview calayer