/UIView-SmoothCorners

An App-Store-safe way to enable smooth continuous corners on UIView that works on iOS 11, 12 and 13.

Primary LanguageObjective-CMIT LicenseMIT

UIView-SmoothCorners

An easy way to enable smooth corners on UIView, without using the private -[CALayer continuousCorners] API (rdar://42040072)

How to use

Swift

As a UIView subclass:

Add SmoothView.swift to your project

let myView = SmoothView()
myView.flx_smoothCorners = true
myView.layer.cornerRadius = 50

(Or change the base class of your main UIView subclass from UIView to SmoothView)

As a UIView category (that swizzles layoutSubviews):

Add UIView+SmoothCorners.h and UIView+SmoothCorners.m to your project Add #import "UIView+SmoothCorners.h" to your bridging header

myView.layer.cornerRadius = 50
myView.flx_continuousCorners = true

Objective-C

As a UIView subclass:

Add FLXSmoothView.h and FLXSmoothView.m to your project

FLXSmoothView *myView = [FLXSmoothView new];
myView.flx_smoothCorners = YES;
myView.layer.cornerRadius = 50;

(Or change the base class of your main UIView subclass from UIView to FLXSmoothView)

As a UIView category (that swizzles layoutSubviews):

Add UIView+SmoothCorners.h and UIView+SmoothCorners.m to your project

myView.layer.cornerRadius = 50;
myView.flx_continuousCorners = YES;

Shortcomings

  • To make things simple for the category approach, I'm not observing the layer's corner radius changes. So make sure the corner radius is set before a layout pass or before setting flx_continuousCorners to true.
  • No cocoapods or carthage support yet