gpt4 book ai didi

iphone - 为什么我不能向 UITableViewCell 的 contentView 添加 mask ?

转载 作者:行者123 更新时间:2023-12-03 19:52:33 24 4
gpt4 key购买 nike

这不可能吗?

我已经尝试过这个:

    UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 20, 200, 30) byRoundingCorners:(UIRectCornerTopRight | UIRectCornerTopLeft) cornerRadii:CGSizeMake(8.0, 8.0)];

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
maskLayer.fillColor = [UIColor blackColor].CGColor;

self.contentView.layer.mask = maskLayer;
self.contentView.layer.masksToBounds = YES;

什么也没发生。但是,如果在 contentView 中的另一个 View 上执行相同的操作,则 mask 将按预期工作。给出了什么?

最佳答案

如果我从最后两行代码中取出“contentView”,它对我有用。我不知道为什么会这样,也许你不能屏蔽内容 View ?

关于iphone - 为什么我不能向 UITableViewCell 的 contentView 添加 mask ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16681110/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com