zoukankan      html  css  js  c++  java
  • iOS--导航栏样式

    push返回按钮样式:

    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
        self.navigationItem.backBarButtonItem = item;
        self.navigationController.navigationBar.tintColor = [UIColor grayColor];
        [self.navigationItem setHidesBackButton:YES];

    自由点击事件:

    //用户协议跳转
        UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick)];
        
        // 2. 将点击事件添加到label上
        [self.UserRate addGestureRecognizer:labelTapGestureRecognizer];
        self.UserRate.userInteractionEnabled = YES; // 可以理解为设置label可被点击

    创建左右导航栏按钮,搜索与个人中心:

    //创建左右导航栏按钮,搜索与个人中心
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[self scaleToSize:[UIImage imageNamed:@"sousuo.png"] size:CGSizeMake(20, 19.6)] style:UIBarButtonItemStylePlain target:self action:@selector(Actionleft:)];
        
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[self scaleToSize:[UIImage imageNamed:@"persons.png"] size:CGSizeMake(20, 20)] style:UIBarButtonItemStylePlain target:self action:@selector(Actionright:)];
    
    
    
    //导航栏个人信息按钮
    -(void)Actionright:(id)send{
        NSLog(@"跳转到个人中心页面");
        PersonalViewController *PersonalView = [self.storyboard instantiateViewControllerWithIdentifier:@"PersonalView"];
        [self.navigationController pushViewController:PersonalView animated:PersonalView];
    }
    //导航栏搜索按钮点击事件
    -(void)Actionleft:(id)send{
        NSLog(@"跳转到搜索页面");
        SearchViewController *search = [self.storyboard instantiateViewControllerWithIdentifier:@"search"];
        [self.navigationController pushViewController:search animated:search];
        
    }
    //设置图片大小
    - (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size{
        // 创建一个bitmap的context
        // 并把它设置成为当前正在使用的context
        UIGraphicsBeginImageContext(size);
         // 绘制改变大小的图片
        [img drawInRect:CGRectMake(0, 0, size.width, size.height)];
         // 从当前context中创建一个改变大小后的图片
        UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
       // 使当前的context出堆栈
        UIGraphicsEndImageContext();
       // 返回新的改变大小后的图片
        return scaledImage;
    }
  • 相关阅读:
    python集成开发环境Anaconda的安装
    hasMap2
    WireShark:TCP三次握手 抓包
    CCF 201409-4 最优配餐
    201403-4 无线网络
    java IO的字节流和字符流及其区别
    平衡二叉树DSW算法
    警惕Java编译器中那些“蜜糖”陷阱
    laravel 学习笔记 —— 神奇的服务容器
    LNMP下安装phpmyadmin的一个小错误解决办法
  • 原文地址:https://www.cnblogs.com/qiyiyifan/p/6265899.html
Copyright © 2011-2022 走看看