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


I am trying to add images in the table cells in the grouped UITableView, but the corners of the images have not been cut.

For example, the first image in the table will only need to the top left corner.

This was my solution, which could use a few refactoring:

 <0> Zero AddRoundedRectToPath (CGContextRef Reference, CGRect Rect, Float Oval Width, Float OvalHit, BOOL Head, BOOL Down) {Float FW, FH; If (ovalwith == 0 = ovalhit == 0) {CGContextAddRect (reference, rect); Return; } CGContextSaveGState (reference); CGContextTranslateCTM (Reference, CGRectGetMinX (rect), CGRectGetMinY (rect)); CGContextScaleCTM (references, oval, oval high); FW = CGRect Gate Width (Rect) / Oval Wideth; FH = CGRactiteHight (Rect) / OvalHit; CGContextMoveToPoint (Reference, FW, FH / 2); CGContextAddArcToPoint (Reference, FW, FH, FW / 2, FH, 0); NSLog (@ "down?% D", below); If (above) {CGContextAddArcToPoint (Reference, 0, FH, 0, FH / 2, 3); } And {CGContextAddArcToPoint (reference, 0, FH, 0, FH / 2, 0); } If (below) {CGContextAddArcToPoint (reference, 0, 0, FW / 2, 0, 3); } And {CGContextAddArcToPoint (reference, 0, 0, FW / 2, 0, 0); } CGContextAddArcToPoint (Reference, FW, 0, FW, FH / 2, 0); CGContextClosePath (reference); CGContextRestoreGState (reference); } - (UIImage *) roundCornersOfage: (UIImage *) Source roundTop: (BOOL) Top roundabout: {BOOL} below {int w = source.size.width; Int h = source.size.height; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB (); CGContextRef Reference = CGBitmapContextCreate (Null, W, H, 8, 4 * W, Color Spaces, KCGImage AlphaEmultidized First); CGContextBeginPath (reference); CGRCR RECORD = CGRactMake (0, 0, W, H); AddRoundedRectToPath (reference, rect, 4, 4, up, down); CGContextClosePath (reference); CGContextClip (reference); CGContextDrawImage (Reference, CGRectMake (0, 0, W, H), Source. CGImage); CGImageRef imageMasked = CGBitmapContextCreateImage (reference); CGContextRelease (reference); CGColorSpaceRelease (colorspace); Return [UIImage imageWithCGImage: imageMasked]; }  

Apply those tasks, then check indexPath to cellForRowAtIndexPath representative to check which corner is.

  if (indexPath.row == 0) {cell.mittweview.image = [self-golfersoffice: cover image roundtop: yes roundabout: no]; } And if (indexPath.row == [indexpoint length]) {cell.imageView.image = [rounded cornersofficial: cover image round top: roundabout: yes]; } Else {cell.imageView.image = coverImage; }  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -