Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 通过外观代理定制UITabbar,而不是直接设置属性(区别、优势…)_Iphone_Ios_Uitabbar_Uiappearance - Fatal编程技术网

Iphone 通过外观代理定制UITabbar,而不是直接设置属性(区别、优势…)

Iphone 通过外观代理定制UITabbar,而不是直接设置属性(区别、优势…),iphone,ios,uitabbar,uiappearance,Iphone,Ios,Uitabbar,Uiappearance,定制uitabar时,我有两种方法,两种方法都可以但我很好奇,哪种方法最好,两种方法都有哪些优点和缺点 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UITabBarController *tbc = (UITabBarController *)self.window.rootViewControl

定制
uitabar
时,我有两种方法,两种方法都可以但我很好奇,哪种方法最好,两种方法都有哪些优点和缺点

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        UITabBarController *tbc = (UITabBarController *)self.window.rootViewController;

        UITabBar *tb = tbc.tabBar;

        // 1. Customizing UITabBar using appearance proxy:
        [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabbar.png"]];
        [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_selected.png"]];


        // 2. Doing the same by setting the properties directly:
        // tb.backgroundImage = [UIImage imageNamed:@"tabbar.png"];
        // tb.selectionIndicatorImage = [UIImage imageNamed:@"tabbar_selected.png"];

        return YES;
    }

外观代理的优点是,您可以随时更改任何控制器的外观,甚至可以利用它保存一些重绘调用

在视图布局时,您对代理对象所做的任何更改都将应用于已存在或随后创建的类的所有实例。但是,您以后仍然可以使用给定实例的方法和属性覆盖代理默认值。

要使用属性进行访问,您需要该控制器的对象,然后才能访问它。
你也可以检查一下

我想你误解了我的问题。我想知道使用
外观代理
与直接使用
选项卡属性
背景图像
的区别/优势。参见
示例代码
1和2上的注释