For complex interfaces, customizing UIView with Code is a pain, so you can use Xib to lay it out.
The approximate steps are as follows:
1. Create a new class in your project and inherit the UIView;
2. Create a new XIB(the name of the XIB is the same as the new class name);
3. In Xib, select the class name that you built for the view change class;
4. To use this uiview is not the same as usual. becausenot us.instantiate it. KeyiUse this static method to instantiate
Of. In this static method, the required parameters are passed.
+ (Lktextview *) Instancetextview {nsarray* Nibview = [[NSBundle mainbundle] loadnibnamed:@ "Lktextview" Owner:nil op Tions:nil]; return [Nibview objectatindex:0]; }
-
5. This uiview can be initialized in Viewcontroller, using it.
Reference blog:http://blog.sina.com.cn/s/blog_637a6d510101dq1l.html
This article is from the "Sheep" blog, please make sure to keep this source http://5934497.blog.51cto.com/5924497/1642024
iOS uses Xib custom UIView