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.
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.
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.
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.
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.
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.
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.
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.
Customized UIView encapsulation can also be placed in the storyboard.
For example, if
TTTAttributedLabel
inheritsUILabel
, dragUILabel
up in the storyboard, and then change the Custom Class toTTTAttributedLabel
in the identity inspector.