iOS UI Implementation Tips

Source: Internet
Author: User

  1. StatusBar Moving Position
    NSString *key = [[NSString alloc] initwithdata:[nsdata datawithbytes: (unsignedChar[]){0x73,0x74,0x61,0x74,0x75,0x73,0x42,0x61,0x72} Length:9] encoding:nsasciistringencoding]; Key=@"StatusBar";//the same effect   ID Object=[UIApplication sharedapplication]; UIView*StatusBar; if([Objectrespondstoselector:nsselectorfromstring (key)]) {StatusBar= [ObjectValueforkey:key]; } statusbar.transform= Cgaffinetransformmaketranslation (self.paneview.frame.origin.x, SELF.PANEVIEW.FRAME.ORIGIN.Y);

  2. TabBar Custom Icons
    if(Floor (Nsfoundationversionnumber) >Nsfoundationversionnumber_ios_6_1) {UIImage*icon = [[UIImage imagenamed:@"jinghua-selected"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; UIImage*unicon = [[UIImage imagenamed:@"Jinghua"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];                [Nc.tabbaritem Setfinishedselectedimage:icon Withfinishedunselectedimage:unicon]; } Else{[Nc.tabbaritem setfinishedselectedimage:[uiimage imagenamed:@"jinghua-selected"] Withfinishedunselectedimage:[uiimage imagenamed:@"Jinghua"]]; } [Nc.tabbaritem settitle:nslocalizedstring (@"Essence", nil)];

  3. Tabbaritem Custom Colors
    [[Uitabbaritem appearance] Settitletextattributes:[nsdictionary Dictionarywithobjectsandkeys: [Uicolor colorwithwhite:113./255Alpha1], Uitextattributetextcolor, nil] forstate:uicontrolstatenormal]; //item Check state color[[Uitabbaritem appearance] Settitletextattributes:[nsdictionary Dictionarywithobjectsandkeys: [Uicolor colorwithwhite: About./255Alpha1], Uitextattributetextcolor, nil] forstate:uicontrolstateselected];

  4. Expand the hit area
    #import<objc/runtime.h>@implementationUicontrol (userinteractoinedgeinsets)Static CharTopnamekey;Static CharRightnamekey;Static CharBottomnamekey;Static CharLeftnamekey;-(void) Setuserinteractionedgeinsets: (uiedgeinsets) edgeinsets{objc_setassociatedobject (self,&Topnamekey, [NSNumber numberWithFloat:edgeInsets.top], objc_association_copy_nonatomic); Objc_setassociatedobject (Self,&Rightnamekey, [NSNumber numberWithFloat:edgeInsets.right], objc_association_copy_nonatomic); Objc_setassociatedobject (Self,&Bottomnamekey, [NSNumber NumberWithFloat:edgeInsets.bottom], objc_association_copy_nonatomic); Objc_setassociatedobject (Self,&Leftnamekey, [NSNumber NumberWithFloat:edgeInsets.left], objc_association_copy_nonatomic);}-(cgrect) enlargedrect{NSNumber* TopEdge = Objc_getassociatedobject (self, &Topnamekey); NSNumber* Rightedge = Objc_getassociatedobject (self, &Rightnamekey); NSNumber* Bottomedge = Objc_getassociatedobject (self, &Bottomnamekey); NSNumber* Leftedge = Objc_getassociatedobject (self, &Leftnamekey); if(TopEdge && rightedge && bottomedge &&Leftedge) {        returnCGRectMake (Self.bounds.origin.x-Leftedge.floatvalue, Self.bounds.origin.y-Topedge.floatvalue, Self.bounds.size.width+ Leftedge.floatvalue +Rightedge.floatvalue, Self.bounds.size.height+ Topedge.floatvalue +bottomedge.floatvalue); }    Else    {        returnSelf.bounds; }}-(uiview*) HitTest: (cgpoint) point withevent: (uievent*)Event{cgrect rect=[self enlargedrect]; if(Cgrectequaltorect (rect, self.bounds)) {return[Super Hittest:point Withevent:Event]; }    returnCgrectcontainspoint (rect, point)?Self:nil;}@end

  5. Tabbarcontroller adding deletes dynamically
    @implementationuitabbarcontroller (Dynamic)-(void) Deletechildviewcontroller: (uiviewcontroller*) controller{if([self.viewcontrollers Containsobject:controller]) {Nsmutablearray*viewcontrollers =[Nsmutablearray arrayWithArray:self.viewControllers];        [Viewcontrollers Removeobject:controller]; Self.viewcontrollers=[Nsarray arraywitharray:viewcontrollers]; }}-(void) Insertchildviewcontroller: (uiviewcontroller*Controller atindex: (nsinteger) index{if(Index >=0&& Index <=self.viewcontrollers.count &&![Self.viewcontrollers Containsobject:controller]) {Nsmutablearray*viewcontrollers =[Nsmutablearray arrayWithArray:self.viewControllers]; if(!viewcontrollers) {Viewcontrollers=[Nsmutablearray array];        } [Viewcontrollers Insertobject:controller atindex:index]; Self.viewcontrollers=[Nsarray arraywitharray:viewcontrollers]; }}@end

  6. Navigationbar Custom
    [ [Uinavigationbar appearance] settitletextattributes:[nsdictionary dictionarywithobjectsandkeys: [UIColor    Whitecolor], Uitextattributetextcolor, nil]]; if([[Uidevice currentdevice].systemversion floatvalue]<7.0) {[Self.navigationbar settintcolor:[uicolor colorwithred:0.0Green194./255Blue196./255Alpha1]]; }Else{[Self.navigationbar setbartintcolor:[uicolor colorwithred:0.0Green194./255Blue196./255Alpha1]]; }

  7. Local language modifications
    [[Nsuserdefaults standarduserdefaults] Setobject:[nsarray arraywithobjects:language, nil]                                              ForKey:  @ "applelanguages"];    [[Nsuserdefaults standarduserdefaults] synchronize];

  8. 2
  9. 2
  10. 2
  11. 2
  12. 22
  13. 2
  14. 2
  15. 2
  16. 22
  17. 333
  18. 3
  19. 33
  20. 3
  21. 3
  22. 3333
  23. 3
  24. 3

iOS UI Implementation Tips

Related Article

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.