• 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]];
    原理是用一个一像素的线图覆盖。

     

  • 相关阅读:
    窗体间传值
    winform 导出datagridview 到excel
    单击单元格任意地方事件
    CLR via 随书笔记
    值类型和引用类型的区别
    System.Object简介
    装箱与拆箱
    静态类
    关于Linq2Sql有外键表的更新引发的问题。
    滑动切换页面
  • 原文地址:https://www.cnblogs.com/sanjianghuiliu/p/3669793.html
Copyright © 2020-2023  润新知