zoukankan      html  css  js  c++  java
  • UITabbar item 设置笔记

      很长一段时间都是用代码来写UITabbarController,试着用xib来写一次,但是遇到tabbar item的图标自定义的时候不知道从何入手,比如定义选定前和选定后的icon图片,这地方还是不太明显。现在用代码记录一下

    [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabBar.png"]];
    或
     [[self.RootTabbarController tabBar] setBackgroundImage:[UIImageimageNamed:@"tabbar.png"]];
     
    
    ITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
        
        selectedImage = [UIImage imageNamed:@"contact"];
        unselectedImage = [UIImage imageNamed:@"contact"];
        UITabBarItem *item3 = [tabBar.items objectAtIndex:2];
        [item3 setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                       COLOR_APP,UITextAttributeTextColor, nil]
                             forState:UIControlStateNormal];
    
    //    [item3 setFinishedSelectedImage:selectedImage
    //        withFinishedUnselectedImage:unselectedImage];
        [item3 setImage:selectedImage];
        [item3 setSelectedImage:selectedImage];
    

      

    这个图片上标记了tabbar item的各种属性

      

    UIimageWithRenderingMode:UIImageRenderingModeAlwaysTemplate这个作为ios7里面的新属性,应该注意
    很多时候在ios7上使用自定义的tabbar,tabbar顶部会出现一个线,此时解决方案

        [[UITabBarappearance] setShadowImage:[[UIImagealloc] init]];
    原理是用一个一像素的线图覆盖。

     

  • 相关阅读:
    linux输入输出及vim管理
    Linux系统结构及常用命令
    Django
    python 基础
    python 路径
    初始化项目结构
    drf操作
    01.Django基础
    Oracle 中如何判断一个字符串是否为数字
    oracle管理权限与角色(篇1)
  • 原文地址:https://www.cnblogs.com/sanjianghuiliu/p/3669793.html
Copyright © 2011-2022 走看看