开发者

iOS custom UITableViewCell hide overflow on top corner

开发者 https://www.devze.com 2023-03-26 12:21 出处:网络
I\'m trying to create a custom table view cell 开发者_高级运维that has a button on the right hand side, such that I can click that button and do something different than when I click the regular cell.

I'm trying to create a custom table view cell 开发者_高级运维that has a button on the right hand side, such that I can click that button and do something different than when I click the regular cell. The problem right now is that on the top cell, where the cell should be rounded, the button is not getting cut off (see picture). I've heard of the view.clipsToBounds property, but I guess I'm not entirely sure how to go about implementing in my custom UITableViewCell class. Thanks for the help!

iOS custom UITableViewCell hide overflow on top corner


You could use a image as background, the image must have the right-high corner rounded. Then use the follow code:

UIImage *corner = [UIImage imageWithContentsOfFile:@"/path/to/image"]; //Or imageNamed:@"image"
purpleButton1.setBackgroundImage:corner forState:UIControlStateNormal];

That should work.

0

精彩评论

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