You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.
The only way to set self.navgitaionItem.title's color is to set TitleTextAttributes instead of the color.
for example.
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor blackColor],NSForegroundColorAttributeName,
nil];
[self.navigationController.navigationBar setTitleTextAttributes:dic];
self.navigationItem.title = @"theTitleIWantToChangeColor";
but the way you offer can;t solve this.
So, I overwrite the method - (void)night_updateColor in UINavigationBar+Night.m and add a property to support that, but this is just a temp way to solve this. Hope you offer a better way to solve this.
我是重写了updatecolor方法,可以丢子典型数据进去
发自网易邮箱大师
在2017年03月12日 21:10,Draveness 写道:
这种方法确实可能会有问题,不过你可以在一个 block 中配置颜色,DKNightVersion 会在每次改变主题时,调用 block
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
The only way to set self.navgitaionItem.title's color is to set TitleTextAttributes instead of the color.
for example.
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor blackColor],NSForegroundColorAttributeName,
nil];
[self.navigationController.navigationBar setTitleTextAttributes:dic];
self.navigationItem.title = @"theTitleIWantToChangeColor";
but the way you offer can;t solve this.
So, I overwrite the method - (void)night_updateColor in UINavigationBar+Night.m and add a property to support that, but this is just a temp way to solve this. Hope you offer a better way to solve this.
(DKColorPicker)dk_titleTintColorPicker {
return objc_getAssociatedObject(self, @selector(dk_barTintColorPicker));
}
(void)dk_setTitleTintColorPicker:(DKColorPicker)picker{
objc_setAssociatedObject(self, @selector(dk_titleTintColorPicker), picker, OBJC_ASSOCIATION_COPY_NONATOMIC);
UIColor *color = picker(self.dk_manager.themeVersion);
NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[color copy],NSForegroundColorAttributeName,
nil];
[self setTitleTextAttributes:navbarTitleTextAttributes];
[self.pickers setValue:[picker copy] forKey:@"setTitleTextAttributes:"];
}
(void)night_updateColor {
[self.pickers enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull selector, DKColorPicker _Nonnull picker, BOOL * _Nonnull stop) {
SEL sel = NSSelectorFromString(selector);
id result = ((DKColorPicker)picker)(self.dk_manager.themeVersion);
if([selector isEqualToString:@"setTitleTextAttributes:"])
{
result = [NSDictionary dictionaryWithObjectsAndKeys:
[result copy],NSForegroundColorAttributeName,
nil];
}
[UIView animateWithDuration:DKNightVersionAnimationDuration
animations:^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self performSelector:sel withObject:result];
#pragma clang diagnostic pop
}];
}];
}
The text was updated successfully, but these errors were encountered: