A
A
Aleksandr Govorukhin2016-04-06 19:32:02
iOS
Aleksandr Govorukhin, 2016-04-06 19:32:02

How to round UIView?

Hello, friends!
Faced a problem, could you explain to me how to round the UIView? What am I doing wrong in the code and how should I do it right? Please explain your answer so that I can understand and understand the whole point in the future.
f56dd26d78064c619f7a391c8740a4a0.png31f264164f2a44f5a8e65d4850e98250.png
Inside the UIView is a Button with a background image.
I want to achieve this effect:
d389c8adc7c0419795b7b728d67249e1.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
ManWithBear, 2016-04-06
@SnapSh0t

view.layer.masksToBounds = true
Oh, and you're doing it in the wrong place. At the time your code is called, the images don't have their actual dimensions.
Move the rounding at least in viewDidApear, or better in viewDidLayoutSubviews
What are these methods and what to do in them can be found here -> CLICK
And a little more here -> CLICK

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question