Rounded rect using UIRectCorner in Swift not working

前端 未结 1 629
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 00:22

I am trying to create a rounded rect for the UITableViewCell I have created in a storyboard. I am using Swift 2 in Xcode 7. I have two views in the prototype cell, topView

相关标签:
1条回答
  • 2020-12-22 00:30

    You have two problems.

    1. awakeFromNib is too early to do anything based on view bounds, because the views haven't been resized for the device at that point. You should create the mask layers in awakeFromNib, but you should set their paths in layoutSubviews.

    2. In setMaskToView(_:corners:), you need to use view.bounds, not self.bounds, to create the path.

    0 讨论(0)
提交回复
热议问题