What is the importance of drawRect, layoutSubViews and setNeedsDisplay methods. In which contexts we should use them?
What is the importance of drawRect, layoutSubViews and setNeedsDisplay methods. In which contexts we
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As in the documentation says:
You use this method to draw your UIView inside a specific rect of a view.
I think that this method let you control if you want the system automatically redraw your UIView for you or not. If you want to control the process by your own state like: if the user click this button, redraw; otherwise, don’t.
Lays out subviews.
I have not much experience with this method. What I can tell you is that you need to override it to layout your subviews