zoukankan      html  css  js  c++  java
  • UIBarButtonItem-添加自定义Left或者Right按钮

    为UINavigationController添加UINavigationItem,我们可以这样写:
     
    1.添加返回导航按钮backBarButtonItem
     
    1.用系统自带的返回按钮

    UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc]

                                              initWithTitle:@"返回"

                                              style:UIBarButtonSystemItemCancel

                                              target:self

                                              action:@selector(doClickBackAction:)];

        self.navigationItem.backBarButtonItem = leftBarButtonItem;

     
    2.自己定义返回按钮

    UIImage* backImage = [UIImage imageNamed:@"btn_back.png"];

        CGRect backframe = CGRectMake(0,0,54,30);

        UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];

        [backButton setBackgroundImage:backImage forState:UIControlStateNormal];

        [backButton setTitle:@"直播" forState:UIControlStateNormal];

        backButton.titleLabel.font=[UIFont systemFontOfSize:13];

        [backButton addTarget:self action:@selector(doClickBackAction:)forControlEvents:UIControlEventTouchUpInside];

        

        UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backButton];

        UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] init];

        self.navigationItem.leftBarButtonItem = leftBarButtonItem;

        [leftBarButtonItem release];

        [backButton release];

    转:http://blog.sina.com.cn/s/blog_7b9d64af0101ab9w.html

  • 相关阅读:
    getBoundingClientRect()方法
    Sublime Text3 安装less
    less知识点总结(一)
    跨域知识(二)——JSONP
    面向过程和面向对象的区别(转)
    暴力+DP:买卖股票的最佳时机
    车的可用捕获量(3.26leetcode每日打卡)
    三维形体的表面积(3.25leetcode每日打卡)
    基础练习:FJ的字符串
    DP:打家劫舍
  • 原文地址:https://www.cnblogs.com/ygm900/p/4578850.html
Copyright © 2011-2022 走看看