美文网首页程序员
IOS 修改UIImagePickerController的na

IOS 修改UIImagePickerController的na

作者: 李筱野 | 来源:发表于2017-12-07 11:16 被阅读67次

    今天偶然间一个朋友问我如何修改UIImagePickerControllertintcolor,我所以然的告诉他,那还不简单吗,就把平时修改controller的方法告诉了他:

    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    

    然而他告诉我说这个方法不行,于是乎我自己试了一下发现果然不行,后来发现原来UIImagePickerController是继承navgationcontroller,这样就导致大家熟悉的方法不能使用,如果想要修改的话需要这样来做:

    UIImagePickerController *controller = [[UIImagePickerController alloc] init];
    if ([controller.navigationBar respondsToSelector:@selector(setBarTintColor:)]) {
                    [controller.navigationBar setTintColor:[UIColor redColor]];
                    [controller.navigationBar setTranslucent:NO];
                }
    

    这样就OK啦!

    相关文章

      网友评论

        本文标题:IOS 修改UIImagePickerController的na

        本文链接:https://www.haomeiwen.com/subject/fgcdixtx.html