zoukankan      html  css  js  c++  java
  • iOS_自定义返回按钮

    //在-(void)viewWillAppear:(BOOL)animated方法中添加返回按钮

    //返回按钮

        UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];

        

        leftButton.frame=CGRectMake(0, 0, 60, 25);

        [leftButton setImage:[UIImage imageNamed:@"back_img"] forState:UIControlStateNormal];

        //设置返回按钮的图片,跟系统自带的“<”符合保持一致

        [leftButton addTarget:self action:@selector(back_click:) forControlEvents:UIControlEventTouchUpInside];

    //图片 居左,

        [leftButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];

        

        UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];

        //ios7.0系统中,自定义的返回按钮 有点 偏右,需要调整位置

        if(([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0?20:0))

        {

            UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace

                                                                                           target:nil action:nil];

            negativeSpacer.width = -8;//这个数值可以根据情况自由变化

            self.navigationItem.leftBarButtonItems = @[negativeSpacer, leftItem];

        }else

        {

            self.navigationItem.leftBarButtonItem = leftItem;

        }

  • 相关阅读:
    java学习笔记(day21)
    linux软件管理之rpm管理rpm包
    linux软件管理之yum管理rpm包
    linux软件管理之概述
    linux存储管理之磁盘配额
    linux存储管理之文件系统
    linux存储管理之mount挂载
    linux存储管理之磁盘阵列
    linux文件管理之链接文件
    linux存储管理之自动挂在
  • 原文地址:https://www.cnblogs.com/sugeladi/p/5159690.html
Copyright © 2011-2022 走看看