How to round the corners of a UIView ios swift 4.1

Kết quả hình ảnh cho round corner view ios swiftAll UIView subclasses have the ability to round their corners thanks to their underlying CALayer – that's the bit that handles the actual drawing of your views. To round the corners of a view, use this code:
yourView.layer.cornerRadius = 10
The number you specify is how far the rounding should go, measured in points. This means that if you have a view that's 128x128 points wide and give it a cornerRadius property of 64, it will look like a circle.
Note that some types of view don't have clipsToBounds enabled by default, which means their corners will not round until you enable this property.
Available from iOS 3.2
Did this solution work for you? Please pass it on!

Comments

Most popular posts

Implementing a Custom Back Button in Swift

Using Realm Mobile Database with Swift 4.0 (Insert, Update, Delete, List)

Chronometer Tutorial With Example In Android Studio

WKWebView advanced tutorial (catch JS events, access properties etc...) (Swift)

How to adjust image content mode using aspect fill, aspect fit and scaling

How to clear all activity stack in Android

From Swift to Javascript and Back

How To: Map, Reduce and Filter in Swift

Extension functions in Kotlin: Extend the Android Framework (KAD 08)

SQL injection in Android content providers and how to be protected