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
You have two problems.
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
.
In setMaskToView(_:corners:)
, you need to use view.bounds
, not self.bounds
, to create the path.