Rounder by UIBezierPath issue when scrolling

I am new in iOS. I am make a chat application. I am using UITableView for display the message chat (one cell - one message). In each cell, I will rounder the message in 2,3 or 4 corner (like Facebook chat)

For rounder I use the UIBezierPath inside layoutSubView of each Tableview Cell

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.messageView.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft) cornerRadii:CGSizeMake(3.0, 3.0)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = self.bounds; maskLayer.path = maskPath.CGPath; self.messageView.layer.mask = maskLayer;

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/wuL6V.png" alt="enter image description here">

<strong>The problem is</strong>, when layout first initial, everything work fine, but when I scroll some cell have wrong rounder ( I figure out the problem is sometime when scroll self.messageView.bounds return wrong value so UIBezierPath draw wrong corner) but I don't know why

How can I prevent it happened? Or Can I have another way to rounder View without UIBezierPath (I google but I only find one way to rounder the UIView is using UIBezierPath :( )? Any help would be appreciated


I had a similar problem and fixed it by moving my corner-rounding code inside tableView:willDisplayCell:forRowAtIndexPath This will allow Cocoa to size things properly.


  • Height and width for landscape mode is showing wrong
  • php's json_encode and character representation
  • Entity Framework and SQL Server Savepoints
  • Serious SpriteKit UIColor bug on iPhone 5S
  • Resizing image for icons for iPad2 - swift
  • Image optimization like whatsapp and instagram in ios and android
  • flask request.json order
  • Loading images on scrollview using lazy loading
  • NSLineBreakByWordWrapping not working ios7
  • Terminated due to memory issue after starting a Loop
  • Adding view above origin of UIScrollView iOS
  • Multiple image in scrollview
  • Opening a File whose Name Contains a Space
  • load store for List using json
  • Swift: inputAccessoryView buttons are not showing
  • UITableViewCell UIButton Selection [duplicate]
  • Localizing day and month in moment.js [duplicate]
  • find out height of a UILabel which is size to fit
  • UIImage in TableView eating memory
  • Border around CCLayer
  • how to add sounds while uiscrollview is scrolling
  • iOS10 widget “Show more” “Show less” bug
  • Disable diagonal dragging in UIScrollview
  • UICollectionView Vertical Paging With Code In Objective-C
  • Combine all UILabels (with proper origins) into a UIImage
  • Multiple field autocomplete with index type boost
  • Change pop-over contentsize using navigationcontroller
  • @ConstructorResult mapping in jpa 2.1
  • In objective C, when presenting a new scene, how do you remove the old scene?
  • create shapes layer in cocos2D
  • Getting podcast metadata from from iPodLibrary
  • iPhone CGContextDrawImage and UIImageJPEGRepresentation drastically slowing down application
  • Tableview button selection wrong after search
  • Rounder by UIBezierPath issue when scrolling
  • Autoresize UIScrollView
  • How to draw to Canvas from SurfaceView?
  • Scaling a pendulum made with SKSpriteNodes
  • Accessing an Object from Class type(+) method in iPhone & Cocos2d?
  • Why doesn't CGContextSetStrokeColorWithColor set text colour to black?
  • JSON - slashes not escaping