Skip to content

Latest commit

 

History

History
73 lines (46 loc) · 2.98 KB

README.md

File metadata and controls

73 lines (46 loc) · 2.98 KB

JSSquircle

CI Status Version License Platform

The difference between a square with round corners and a Squircle is small but can have a big impact on the overall feel of your app - https://99percentinvisible.org/article/circling-square-designing-squircles-instead-rounded-rectangles/

Your typical layer.cornerRadius rounded rectangle has a constant corner radius, it's like placing 4 perfect circles on each corner, the result is a slightly jarring transition from straight to curve. A squircle, on the other hand, gently increases the curve at it goes from straight-edge to rounded corner. Making it more of an elipse than a perfect circle.

Apple uses the Squircle A LOT in their designs: AppleIcons Image source

AppleHardware Image source

SquircleExampleImage Image source

Installation

JSSquircle is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'JSSquircle'

Usage

Programmatic

Use the class Squircle exactly the same as you would UIView, just set the cornerRadius property and you're good to go.

If you created a roundedRect like this:

let roundedRect = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 50))
roundedRect.layer.cornerRadius = 10
self.view.addSubview(roundedRect)

To replace this with a smooth Squircle all you need to do is import this module and then replace UIView with Squircle like so:

import JSSquircle

let roundedRect = Squircle(frame: CGRect(x: 0, y: 0, width: 200, height: 50))
roundedRect.layer.cornerRadius = 10
self.view.addSubview(roundedRect)

Storyboard

Add a UIView to your Storyboard as normal, then change the Class under Identity inspector from UIView toSquircle.

IdentityInspector

Then set the cornerRadius to whatever you'd like in the Attributes inspector.

AttributesInspector

That's it!

Author

Janak Shah, janakshah.com

License

JSSquircle is available under the MIT license. See the LICENSE file for more info.