Extendedlayout in IOS 7

Source: Internet
Author: User

Reference article:

http://stackoverflow.com/questions/18798792/ Explaining-difference-between-automaticallyadjustsscrollviewinsets-extendedlayo

http://redth.codes/ios7-full-screen-layout/

IOS 7 later introduced a series of properties in Viewcontroller to manage page layouts.

Here's an explanation from Apple's official documentation, which is too abstract to read, so experiment with the code.

extendedLayoutIncludesOpaqueBars

A Boolean value indicating whether or not the extended layout includes opaque bars.automaticallyAdjustsScrollViewInsets

A Boolean value that indicates whether the view controller should automatically adjust its scroll view insets.

edgesForExtendedLayout Property

The extended edges to use for the layout.EdgesforextendedlayoutCreate a new item for a single page, then add Uinavigationcontroller to set the background to red, the interface effect is as follows: So you can see that after iOS7, the layout of the view is the default full screen, Navigation bar is semi-transparent by default, You can see the red background below the navigation bar.
-(void) viewdidload {    [super viewdidload];    Self.edgesforextendedlayout = Uirectedgenone;}

Set the edgesforextendedlayout to Uirectedgenone, indicating that the view is not extended to the entire screen. The page works as follows:

 

Uirectedge is an enumeration type, and the other values are very easy to understand by literal means.

typedef enum:nsuinteger {   Uirectedgenone   = 0,   uirectedgetop    = 1 << 0,   uirectedgeleft   = 1 << 1,   uirectedgebottom = 1 << 2,   uirectedgeright  = 1 << 3,   uirectedgeall = Uirectedge Top | Uirectedgeleft | Uirectedgebottom | Uirectedgeright} Uirectedge;

automaticallyAdjustsScrollViewInsets 

This property is used if the page is ScrollView or uitableview, and usually we want the ScrollView or uitableview content to appear below the Uinavigation bar.

By setting Edgesforextendedlayout = Uirectedgenone or self. Navigationcontroller. Navigationbar. Translucent = no; You can have the layout of the view start from below the Uinavigation bar, but one side effect is that when the page is sliding, view has no way to occupy the full screen.

Automaticallyadjustsscrollviewinsets will be able to complete this requirement well.

Self.automaticallyadjustsscrollviewinsets = NO;

At this time UITableView will be blocked by Uinavigation bar.

Self.automaticallyadjustsscrollviewinsets = YES;

At this point you can see that the content of UITableView will start from below Uinavigation Bar, and the view of this page still occupies the entire screen, so this property is completely done!

Extendedlayout in IOS 7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.