UITextView CornerRadius in cell

I have a table, there is a cell that contains contentView, on which UIView, and in it UITextViewI already need for the cornerRadiustop left, top right, bottom left (as in the picture)

It should be

But in case of launching the application, it shows me like this:

as is

If you scroll the table (scroll this cell) and vice versa, then it is displayed as necessary. Help to do this in the case of starting directly, it was displayed as needed, here is the code that is responsible for it cellForRowAtIndexPath:

UIRectCorner rectCorner = UIRectCornerTopLeft | UIRectCornerBottomLeft | UIRectCornerTopRight;

    UIBezierPath *maskPath;
    maskPath = [UIBezierPath bezierPathWithRoundedRect:cell.viewMessage.bounds//cell.viewMessage.bounds
                                     byRoundingCorners:rectCorner
                                           cornerRadii:CGSizeMake(20.0, 20.0)];

    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

    maskLayer.path = maskPath.CGPath;

    cell.viewMessage.layer.masksToBounds = YES;

    cell.viewMessage.layer.mask = maskLayer;
+4
source share
2 answers

, , . .

  • UITableViewCell .xib ( ).
  • xib IBOutlet. () viewMessage.
  • , UITableView,

    - (void)viewDidLoad {
        [self.tableview registerNib:[UINib nibWithNibName:@"UITableviewCellclassname" bundle:nil] forCellReuseIdentifier:@"cell"];
    }
    

, , ... , . , , - :) enter image description here

+1

, viewMessage - .

maskLayer initWithCoder / initWithFrame, maskLayer layoutSubviews viewMessage.

: UIBezierPath

+1

Source: https://habr.com/ru/post/1626012/


All Articles