From: http://www.jianshu.com/p/bcf86b170d9c
Objective
Why would you write this? Because in the iOS development, the layout of the interface has no Android layout has so many methods and advantages, my personal development is pure code, masonry This framework I also do not use in development, one is the code layout, the amount of code is more, in addition, as if there is a problem in the iOS10 layout, There are some ways to solve the problem on the Internet.
So just want to be able to customize some UI controls to make the layout easier
Implementation ideas
Like Android Wrap_content, Uilabel can show the width and height of the control based on the content.
Currently available in the Zfui framework only Uilabel and UIButton methods are available
They all inherit the corresponding parent class, and then rewrite the method in the parent class to make the control easier and easier to use
Implementation method
Directly on the code, demo and framework can go to GitHub to download
Https://github.com/joshuaGeng/ZFUI-Framework
First, add the Zfui.framework to the project.
method to invoke
#import <ZFUI/ZFUI.h>
To create a label method
Zfuilabel *label = [[Zfuilabel alloc] init];
Label.numberoflines = 0;
Label.backgroundcolor = [Uicolor Greencolor];
[Label setlabeltext:@ "HelloWorld" Andwithframe:cgrectmake (100, 70, 0, 0)];
Label.iscancopy = YES;
Label.titlecopy = @ "Copy";
Set different colors
[Label SetAttributeColorWithAllStr:label.text Andallcolor:[uicolor Redcolor] andwithdiffstr:@ "World" anddiffcolor:[ Uicolor Blackcolor]];
[Self.view Addsubview:label];
button
Zfuibutton *button = [[Zfuibutton alloc] Initwithframe:cgrectmake (100, 120, 120, 60)];
[Button setimage:[uiimage imagenamed:@ "img"] forstate:uicontrolstatenormal];
[Button settitle:@ "button" forstate:uicontrolstatenormal];
Button.backgroundcolor = [Uicolor Orangecolor];
Button.btnimgrect = CGRectMake (10, 20, 22, 21);
Button.btntitlerect = CGRectMake (50, 20, 120, 30);
[Self.view Addsubview:button];
Currently provides the ZFUI framework only provides the Uilabel and UIButton methods, the follow-up will continue to update, there is a need to download, the comments in the demo is very detailed.
IOS develops Zfui framework controls to make layout easier