search

Home  >  Q&A  >  body text

ios - 像知道像新浪微博用户资料这样的复杂一些的界面应该怎么处理视图?

比如【详细资料】,【微博】,【粉丝】等等那一行,是应该把每个UILabel或者UIButton自定义到一个UIView的子类里面,还是在Controller里一个一个加进去?

伊谢尔伦伊谢尔伦2768 days ago651

reply all(5)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 11:51:04

    These buttons have similar UI, so if I get such a UI draft I will definitely customize a UIButton, two sub-UILabels up and down, and expose setText and the like. Secondly, even if it is not a View that will be reused immediately, because the number + text description is a UIButton as a whole, I think it is not very reasonable to assemble it in the Controller, and it will still be abstracted into a custom View.

    reply
    0
  • PHPz

    PHPz2017-04-17 11:51:04

    Personally, I think it’s better to encapsulate it, the logic will be clearer, and it won’t have much impact if you don’t encapsulate it.

    reply
    0
  • PHPz

    PHPz2017-04-17 11:51:04

    If it were me, I wouldn’t encapsulate it and just add it directly to the viewcontroller. I think encapsulation doesn’t make much sense. It is also recommended that you use storyboard to directly visualize the design. It is simple and easy to use, saves a lot of layout code, and supports horizontal screen automatic layout and high-level automatic layout adaptation.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 11:51:04

    There is no problem if there is no encapsulation, but encapsulation is better for management, the logic is clearer, and it is easier to change if you want to change it.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 11:51:04

    Customized UIView encapsulation can also be placed in the storyboard.
    For example, if TTTAttributedLabel inherits UILabel, drag UILabel up in the storyboard, and then change the Custom Class to TTTAttributedLabel in the identity inspector.

    reply
    0
  • Cancelreply