Tag view and block in iOS

Source: Internet
Author: User

Label View Controller-UitabbarcontrollerCustom UitabbaritemCustomize the navigation bar and tab bar background pictureintegrated use of three view controllers
I. Tag View controller UitabbarcontrollerUitabbarcontroller has the following important propertiesViewcontrollers The View controller displayedtabBar Tab BarDelegate Protocol
TabBar is a Uitabbar object that contains multiple Uitabbaritem, one viewcontroller for each tanbaritem. Tabbar Height for

When more than five Tabbaritem, the system will automatically add a more button, click More buttons, not at the bottom of those buttons will
appear in a list

Uiappearance
If you want to set all the Navigation view controller color by one button, similar to QQ one-button skin-changing operation, can be operated through the Uiappearance protocol, through which you can customize the color of some controls, etc.
Uitabbarcontroller * tab = [[Uitabbarcontroller alloc] init];    Tab.delegate = self;    [Tab SETHIDESBOTTOMBARWHENPUSHED:NO];        Nsarray * arr = [Nsarray arraywithobjects:nav,nav2,nav3,nav4,nav5,nav6, nil];    [Tab Setviewcontrollers:arr];    The color of the whole strip    [Tab.tabbar Setbartintcolor:[uicolor whitecolor];    Color of each icon    [Tab.tabbar settintcolor:[uicolor Orangecolor];

Summary
Uitabbarcontroller is a common layout style in project development, and unlike Uinavigationcontroller, its viewcontroller are tied, And the Uinavigationcontroller is hierarchical.
Uitabbatcontroller,uinavigationcontroller and Uitableviewcontroller, usually a combination, this layout is particularly common, it must be skilled application

Uitabbarcontroller can be nested Uinavigationcontroller

Uinavigationcontroller can also be nested Uitabbatcontroller


IOS block Usagein iOS, the definition uses "^" to indicate the block variable, the content is contained in "{}", and as in the C language, with "; "To represent the end of the statement
int multiplier = 7;

Int (^myblock) (int) = ^ (int num) {return num * multiplier;};

"^" declares that this is a block, "Myblock" is the variable name

Block return value type int type
parameters of type intparameter is named "num"


No return type no parameter type block-(void) testfirstblock{void (^myblock) () = ^ () {NSLog (@ "I lost >3<");    };    NSLog (@ "who goes First"); Myblock ();}    -(void) testsecondblock{void (^twoblock) (NSString *) = ^ (NSString * str) {NSLOG (@ "str = =%@", str);    };    Twoblock (@ "Walk with Hand"); Twoblock (@ "pig dots");} No return value multiple parameters-(void) testthirdblock{void (^thirdblock) (nsstring *,int) = ^ (NSString * Str,int a) {NSLog (@ "int = =%    D,str = =%@ ", a,str);    }; Thirdblock (@ "(?????)", 55555);}                There are return values with parameters-(void) testforthblock{int (^forthblock) (nsstring *,nsinteger) = ^ (NSString * Value,nsinteger num) {                int strvalue = [value intvalue];    return strvalue+num;        };        int d = forthblock (@ "77", 2); NSLog (@ "(?????) A = =%d ", d);} Change background color-(void) testcolorblock{void (^myblock) (Uicolor *) = ^ (Uicolor * color) {[Self.view Setbackgroundcolor:co    LOR];    };    Self.teseblock = Myblock; NSLog (@ "TextBlock = =%@", self.teseblock);}


Block Considerationssince the variables created by block are divided into two memory regions, the global and the stack, it is necessary to copy the block's member variables or attributes into the heap memory in iOS if they are used.

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.