How do I add a UIImage to grouped UITableViewCell so it rounds the corners?

后端 未结 5 709
囚心锁ツ
囚心锁ツ 2021-02-14 14:38

I\'m trying to add images to table cells in a grouped UITableView but the corners of the images are not clipped. What\'s the best way to go about clipping these (besides clippin

5条回答
  •  逝去的感伤
    2021-02-14 15:00

    There is built-i way if you want to just display the rounded corners. Put the image in a UIImageView and then set the cornerRadius of the layer of the UIImageView. You will also need to tell the UIImageView to clip to bounds but that will give you rounded corners.

    UIImageView *myImageView = [[UIImageView alloc] initWithImage:...];
    [myImageView setClipsToBounds:YES];
    [[myImageView layer] setCornerRadius:5.0f];
    

提交回复
热议问题