iPhone – Group UITableViews and images masking

Therefore, for the grouped UITableView, I want the image in the imageView placed in the topView of the UITableViewCell to look like this (from the iTunes application):

< p>Instead, I got this:

The part doesn’t seem to obscure the image view of the cell. Why not? I have tried everything I can think of. As far as I know, this is a swamp standard setting. UITableView is part of UITableViewController and there is no custom UITableViewCell.

Has anyone else encountered this ? Is there an easy way to customize UITableViewCells to achieve this? I tried Matt Gallagher’s code, but he didn’t cover up the image in the top (and bottom) row.

Hope it’s not obvious to me-but did you try to set imageView.clipsToBounds?

(It’s not like that, I just tried it.)

This is the hard way…

 #import 


cell.imageView.layer.masksToBounds = YES;
cell.imageView.layer.cornerRadius = 9.0;

< p>(At least it is set to “Retina” in 9.0 on my emulator.)

This will leave an image with four rounded corners, which is not what you want, but Halfway. Now, if you crop the image and then do a two-stage replacement, first replace the right edge of the image with rectangles (top right and bottom right), and then replace what you want with the small rectangle at the bottom left. Picky I know, but I don’t I think there is a simple answer.

I think the most appropriate approach may be to combine it into a UIImage, the corners you need are transparent, and then only apply special UIImage instead of normal in cellForRowAtIndexPath Image, if it is a group-first or group-last cell.

CGContextClipToMask looks like the one to be used.

So, for Grouped UITableView, I want the image in the imageView placed in the topView of the UITableViewCell to look like this (from the iTunes application):

Instead, I got this:

< p>This part does not seem to obscure the image view of the cell. Why not? I have tried everything I can think of. As far as I know, this is a swamp standard setting. UITableView is part of UITableViewController and there is no custom UITableViewCell.

Has anyone else encountered this ? Is there an easy way to customize UITableViewCells to achieve this? I tried Matt Gallagher’s code, but he didn’t cover up the image in the top (and bottom) row.

Hope it’s not obvious to me-but you try to set imageView.clipsToBounds?

(It’s not like that, I just tried it.)

This is the hard way…

 #import 


cell.imageView.layer.masksToBounds = YES;
cell.imageView.layer.cornerRadius = 9.0;

< p>(At least it is set to “Retina” in 9.0 on my emulator.)

This will leave an image with four rounded corners, which is not what you want, but Halfway. Now, if you crop the image and then do a two-stage replacement, first replace the right edge of the image with rectangles (top right and bottom right), and then replace what you want with the small rectangle at the bottom left. Picky I know, but I don’t I think there is a simple answer.

I think the most appropriate approach may be to combine it into a UIImage, the corners you need are transparent, and then only apply special UIImage instead of normal in cellForRowAtIndexPath Image, if it is a group-first or group-last cell.

CGContextClipToMask looks like the one to be used.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1066 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.