Skip to content
An easy way to enable smooth continuous corners on UIView
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Objective-C Example Add Swift/Obj-C UIView subclasses Mar 31, 2019
Swift Example Add Swift/Obj-C UIView subclasses Mar 31, 2019
.gitignore Initial commit Mar 19, 2019
FLXSmoothView.h
FLXSmoothView.m
LICENSE
README.md Add Swift/Obj-C UIView subclasses Mar 31, 2019
SmoothView.swift
UIView+SmoothCorners.h Initial commit Mar 19, 2019
UIView+SmoothCorners.m Check for bounds change before updating the mask Mar 21, 2019

README.md

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()
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
You can’t perform that action at this time.