Sagit.Framework For IOS automatic layout tutorial: 4. Main interface: relative level uiview layout, using block syntax.

Time:2020-10-29

preface:

The interface of IOS is divided into status bar, navigation bar, main interface and bottom status bar.

This article describes the relative level of the main interface uiview layout, and the use of block syntax, the operation of the other three, in other articles.

Basic definition of block block block:

@interface UIView (STUIViewEvent)
typedef  void(^ViewDescription)(id view);
#Pragma mark added description
//! provide a code block to facilitate the description of code block in code specification description
-(UIView*)block:(NSString*)description on:(ViewDescription)descBlock;
@end

The definition of block can be used to describe the function description of a group of UI, and also can be used to write the layout of UI.

Through the block writing method, the layout code is more hierarchical

1. Example code:

 

After adding a uiview, through block, you can continue to append attribute control, or you can add subviews in the.

The on parameter of block block block is ID by default, which can be modified to the specific uiview type (such as uibutton and uilabel)

 

Recommended Today

Blog based on beego, go blog

Go Blog A beego based development, can quickly create personal blog, CMS system Include functions see Official website of go bloggo-blog.cn Demo siteleechan.online Update log time function January 23, 2020 New top post function February 2, 2020 New custom navigation function February 4, 2020 New site announcement function February 6, 2020 New link module February […]