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;

The problem is, 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With