开发者

How to make CALayer resizeable?

How can I make CALayer resizable? When I insertSublayer into tableViewCell, then change the cell height, how can I make it fit to the new size of the cell?

CALayer *innerShadowLayer = [CALayer layer];
innerShadowLayer.contents = (id)[UIImage imageNamed: @"innershadow"].CGImage;
innerShadowLayer.contentsCenter = CGRectM开发者_StackOverflow社区ake(10.0f/21.0f, 10.0f/21.0f, 1.0f/21.0f, 1.0f/21.0f);
innerShadowLayer.frame = cell.frame;    
[cell.backView.layer insertSublayer:innerShadowLayer atIndex:0];


I am not sure where you are placing this code, but if it's in the UITableViewCell subclass then you can save it as an instance variable and add this code

- (void)layoutSubviews{
    [super layoutSubviews];
    innerShadowLayer.frame = cell.frame;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜