Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Latest commit

 

History

History
45 lines (38 loc) · 1.71 KB

README.md

File metadata and controls

45 lines (38 loc) · 1.71 KB

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