Search code examples
ios6uiwebviewcalayer

UIWebView corners not rounded


I am using a UIWebView for displaying some formatted text. I am using the line:

sliderTextWebview.layer.cornerRadius = 10;

to round the corners of the UIWebview. The corners are not rounded but if you pull the text in the view down or up you can see the rounded corners of the UIWebView behind. It appears that the text frame sits above the web view background, but this frame's corners are not rounded.


Solution

  • Try

    sliderTextWebview.layer.masksToBounds = YES
    

    For Swift 4+, it should be

    sliderTextWebview.layer.masksToBounds = true