Vadim Belyaev Profile picture
May 29 9 tweets 3 min read
(1/9) How to make beautiful rounded corners in #SwiftUI, a thread: Image
(2/9) The easiest way to round corners of any SwiftUI view is to add a .cornerRadius modifier.
Here's how it looks like: Swift code: Text(".cor...
(3/9) It's okay at a first glance, but if you look closely, you may notice that it's more like two segments attached to each other rather than a single curve. If you don't see what I mean, try looking at the picture from afar or from the side. Enlarged blue rounded recta...
(4/9) Now, let's use a .clipShape modifier, using a RoundedRectagle with .continuous corner style: Swift code: Text(".cli...
(5/9) This looks much better and more natural. The form of the curve resembles the way objects bend in real life.

Here I colored the .clipShape option yellow and put it on top of the .cornerRadius option, which is still blue. The difference is now prominent: A yellow rectangle with rou...
(6/9) Here's an animation of how these buttons transition into each other which also helps to see the difference (if the quality is poor, blame Twitter!):
(7/9) I don't know what's the performance cost of .clipShape compared to .cornerRadius, but if I had to guess, it should be negligible unless you have a lot of views with rounded corners on screen.
(8/9) After reading this thread, you'll probably start noticing imperfectly rounded corners everywhere: sorry about that!
(9/9) Conclusion: whenever possible, instead of .cornerRadius use a .clipShape with a RoundedRectangle that has a .continuous style, and your rounded corners will look gorgeous.

Here's the code I used for the thread: gist.github.com/vadimbelyaev/1…

Have fun with #SwiftUI!

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Vadim Belyaev

Vadim Belyaev Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @vdbv

Jul 4, 2020
Сегодня я случайно решил почитать документацию по SQLite. Я офигел и прозрел. Если вкратце, то SQLite — это такой джаваскрипт в мире баз данных. Тред с весёлыми запросами в консоли:
1. В SQLite, как и в любой БД, полям таблиц задают типы. Но можно записать значение любого типа в любое поле. SQLite его сконвертирует в нужный тип, а если не сможет, запишет как есть. Image
2. Неявное приведение типов можно не заметить, пока явно не проверишь функцией typeof(). Видно, что строка '42' сконвертировалась в целое число 42, потому что у поля тип INTEGER, а число 33950 записалось строкой. Image
Read 15 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(