Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subclass UIView or UIViewController

I want to make a "section" which has an image and some text below it.

Should I be subclassing UIView or UIViewController? I'm thinking UIView as it won't know what image or what text to display, just that there will be both. Also if it is UIView, what method do I add the subviews (UIImageView and UILabel) in as subviews? Or should I draw the the text and image, without using UIImageView or UILabel in drawRect?

like image 538
Jonathan. Avatar asked Sep 05 '26 15:09

Jonathan.


1 Answers

  • Subclass UIView
  • Add the subviews (UIImageView and UILabel) in initWithFrame:
  • Layout the subviews in layoutSubviews
  • Do additional custom drawing in drawRect:, if needed
like image 114
Bitgamma Avatar answered Sep 09 '26 00:09

Bitgamma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!