zoukankan      html  css  js  c++  java
  • IOS 自定义导航栏标题和返回按钮标题

    IOS中自定义导航栏标题:

     UILabel *titleText = [[UILabel alloc] initWithFrame: CGRectMake(160, 0, 120, 50)];
    
     titleText.backgroundColor = [UIColor clearColor];
    
     titleText.textColor=[UIColor whiteColor];
    
     [titleText setFont:[UIFont systemFontOfSize:17.0]];
    
     [titleText setText:@"XXX"];
    
     self.navigationItem.titleView=titleText;
    
     [titleText release];

    IOS中自定义导航栏返回按钮:(放在pushViewController之前)

    UIBarButtonItem *backItem=[[UIBarButtonItem alloc]init];
    
      backItem.title=@"后退";
    
      backItem.tintColor=[UIColor colorWithRed:129/255.0 green:129/255.0  blue:129/255.0 alpha:1.0];
    
      self.navigationItem.backBarButtonItem = backItem;
    
      [backItem release];

     IOS中自定义导航栏右边按钮:

    UIBarButtonItem * rightButton = [[UIBarButtonItem alloc]
    
                                                    initWithTitle:@"回到首页"
    
                                                    style:UIBarButtonItemStyleBordered
    
                                                    target:self
    
                                                    action:@selector(callModalList)];
    
     
    
    rightButton.image=[UIImage imageNamed:@"right_button.png"];
    
    rightButton.tintColor=[UIColor colorWithRed:74/255.0 green:74/255.0 blue:74/255.0 alpha:1.0];
    
    self.navigationItem.rightBarButtonItem = rightButton;
    
    [rightButton release];

    或者

        //设置返回按钮
    
        UIButton* backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
        [backButton setBackgroundImage:[UIImage imageNamed:@"btn_public_back"] forState:UIControlStateNormal];
    
        backButton.frame = CGRectMake(0, 0, 35,35);
    
        [backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    
        leftBarItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
        self.navigationItem.leftBarButtonItem = leftBarItem;
  • 相关阅读:
    [NOI2009]管道取珠 DP + 递推
    poj3207 Ikki's Story IV
    NOIP2016Day1T2天天爱跑步(LCA+桶)
    NOIP2016Day2T3愤怒的小鸟(状压dp) O(2^n*n^2)再优化
    NOIP2016Day1T3换教室(floyd+期望dp)
    bzoj1854: [Scoi2010]游戏(匈牙利) / GDKOI Day2 T2(最大流)
    [CodeVs4927]线段树练习5
    基数排序的奇技淫巧
    bzoj2724: [Violet 6]蒲公英(离散化+分块)
    bzoj1483: [HNOI2009]梦幻布丁(链表+启发式合并)
  • 原文地址:https://www.cnblogs.com/tangaofeng/p/5163045.html
Copyright © 2011-2022 走看看