An easy way to enable smooth corners on UIView, without using the private -[CALayer continuousCorners]
API (rdar://42040072)
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
)
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
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
)
Add UIView+SmoothCorners.h
and UIView+SmoothCorners.m
to your project
myView.layer.cornerRadius = 50;
myView.flx_continuousCorners = YES;
- 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
totrue
. - No cocoapods or carthage support yet