Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bar button item states #190

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions NUI/Core/NUIAppearance.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ + (void)initUIBarButtonItem
NSString *className = @"BarButton:BarButtonBack";
Class uiClass = [UIBarButtonItem class];

NSDictionary *titleTextAttributes = [NUIUtilities titleTextAttributesForClass:className];

if ([[titleTextAttributes allKeys] count] > 0) {
[[uiClass appearance] setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
}

[self setTitleTextAttributesForClass:uiClass nuiClass:className suffix:nil state:UIControlStateNormal];
[self setTitleTextAttributesForClass:uiClass nuiClass:className suffix:@"selected" state:UIControlStateSelected];
[self setTitleTextAttributesForClass:uiClass nuiClass:className suffix:@"highlighted" state:UIControlStateHighlighted];
[self setTitleTextAttributesForClass:uiClass nuiClass:className suffix:@"disabled" state:UIControlStateDisabled];

if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
[[uiClass appearance] setTintColor:[NUISettings getColor:@"background-tint-color" withClass:className]];
}
Expand All @@ -50,4 +49,17 @@ + (void)initUIBarButtonItem

}

+ (void)setTitleTextAttributesForClass:(Class)uiClass nuiClass:(NSString *)nuiClass suffix:(NSString *)suffix state:(UIControlState)controlState
{
NSDictionary *textAttributes;
if (suffix) {
textAttributes = [NUIUtilities titleTextAttributesForClass:nuiClass withSuffix:suffix];
} else {
textAttributes = [NUIUtilities titleTextAttributesForClass:nuiClass];
}

if ([[textAttributes allKeys] count] > 0) {
[[uiClass appearance] setTitleTextAttributes:textAttributes forState:controlState];
}
}
@end
5 changes: 5 additions & 0 deletions NUI/Core/Renderers/NUIBarButtonItemRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ + (void)render:(UIBarButtonItem*)item withClass:(NSString*)className
[item setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
}

NSDictionary *selectedTextAttributes = [NUIUtilities titleTextAttributesForClass:className withSuffix:@"selected"];

if ([[selectedTextAttributes allKeys] count] > 0) {
[item setTitleTextAttributes:selectedTextAttributes forState:UIControlStateSelected];
}
}

@end
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ To see all of the available properties and values, see the Style Classes and Sty

### Creating Custom Style Classes

You can give elements custom style classes (e.g. `LargeButton`), and make those classes inherit from one or more other style classes by using the form `Button:LargeButton`. To bypass NUI's styling for a particular element, set the class to `none`. You can set an element's style class either in Interface Builder or programmatically:
You can give elements custom style classes (e.g. `LargeButton`), and make those classes inherit from one or more other style classes by using the form `Button:LargeButton`. To bypass NUI's styling for a particular element, set the class to `none`. You can set an element's style class either in Interface Builder or programmatically:

#### Setting an Element's Style Class in Interface Builder

Expand Down Expand Up @@ -190,6 +190,21 @@ Below are all of the currently available style classes, their corresponding UI c
* font-size *(Number)*
* text-shadow-color *(Color)*
* text-shadow-offset *(Offset)*
* font-color-selected *(Color)*
* font-name-selected *(FontName)*
* font-size-selected *(Number)*
* text-shadow-color-selected *(Color)*
* text-shadow-offset-selected *(Offset)*
* font-color-highlighted *(Color)*
* font-name-highlighted *(FontName)*
* font-size-highlighted *(Number)*
* text-shadow-color-highlighted *(Color)*
* text-shadow-offset-highlighted *(Offset)*
* font-color-disabled *(Color)*
* font-name-disabled *(FontName)*
* font-size-disabled *(Number)*
* text-shadow-color-disabled *(Color)*
* text-shadow-offset-disabled *(Offset)*

#### BarButtonBack

Expand All @@ -207,6 +222,21 @@ Below are all of the currently available style classes, their corresponding UI c
* font-size *(Number)*
* text-shadow-color *(Color)*
* text-shadow-offset *(Offset)*
* font-color-selected *(Color)*
* font-name-selected *(FontName)*
* font-size-selected *(Number)*
* text-shadow-color-selected *(Color)*
* text-shadow-offset-selected *(Offset)*
* font-color-highlighted *(Color)*
* font-name-highlighted *(FontName)*
* font-size-highlighted *(Number)*
* text-shadow-color-highlighted *(Color)*
* text-shadow-offset-highlighted *(Offset)*
* font-color-disabled *(Color)*
* font-name-disabled *(FontName)*
* font-size-disabled *(Number)*
* text-shadow-color-disabled *(Color)*
* text-shadow-offset-disabled *(Offset)*

#### Button

Expand Down