robertwijas / uiss Goto Github PK
View Code? Open in Web Editor NEWUIAppearance Stylesheets
License: MIT License
UIAppearance Stylesheets
License: MIT License
It would be nice if you can insert simple NSStrings to UIAppeareance.
Something like:
{
"ExampleView":{
"fontName" :"Optima-Italic",
}
}
For the following class:
@interface ExampleView : UIView
@Property(nonatomic) UI_APPEARANCE_SELECTOR NSString *fontName;
@EnD
how to change images in UISearchBar and UINavigationBar ?
in UISearchBar need to change:
and in UINavigationBar:
Hi,
I'm using Swift 3.0.
"titleColor:highlighted": "white"
This is not working. Also i tried UISS pod but error
[!] Unable to find a specification for UISS (~> 1.1.0)
Also there is no class UIButton+UISS in my version from git.
-Thanks !!
Hi, I am getting a compiler error in the most recent code from master. It appears that dispatch_release (used by the dealloc method in uiss.m) is not allowed if the project is targeting iOS 6.0 and above.
I found this information which might be relevant:
http://stackoverflow.com/questions/8618632/does-arc-support-dispatch-queues
In particular: "...if your deployment target is at least iOS 6.0 or Mac OS X 10.8, and you have ARC enabled, ARC will retain and release your queue, and the compiler will flag any attempt to use dispatch_retain or dispatch_release as an error."
Hope that helps!
Tim
Getting a couple of errors in the library (1.1.0 from Cocoapods):
[self dismissModalViewControllerAnimated:YES]; on line 90 in UISSConsoleViewController.m
NSAssert(dispatch_get_current_queue() == dispatch_get_main_queue(), @"notifications should arrive on main thread", nil); on line 145 in UISSStatusViewController.m
I fixed the first one (replaced it with: [self dismissViewControllerAnimated:YES completion:nil];). Not sure how to fix the second one though, not alot of experience with GCD.
First of all, great work, Robert!
You should put a note somewhere that you cannot use comments in the uiss.json, this seems to break the system.
Can i know when the UISS 2.0 will be available ?
Can i create two styles and apply one on button1 and another on button2 ??
When i run UISS on iOS 7 i got this message
Ld /Users/knetmac3/Library/Developer/Xcode/DerivedData/ThemesDemo-gqxxcwvjavqbeeettltrpfsohmoe/Build/Products/Debug-iphonesimulator/ThemesDemo.app/ThemesDemo normal i386
cd /Users/knetmac3/Desktop/ThemesDemo
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Users/knetmac3/Library/Developer/Xcode/DerivedData/ThemesDemo-gqxxcwvjavqbeeettltrpfsohmoe/Build/Products/Debug-iphonesimulator -F/Users/knetmac3/Library/Developer/Xcode/DerivedData/ThemesDemo-gqxxcwvjavqbeeettltrpfsohmoe/Build/Products/Debug-iphonesimulator -filelist /Users/knetmac3/Library/Developer/Xcode/DerivedData/ThemesDemo-gqxxcwvjavqbeeettltrpfsohmoe/Build/Intermediates/ThemesDemo.build/Debug-iphonesimulator/ThemesDemo.build/Objects-normal/i386/ThemesDemo.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -ObjC -framework Foundation -framework UIKit -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -framework CoreGraphics -framework UIKit -framework Foundation -lPods -Xlinker -dependency_info -Xlinker /Users/knetmac3/Library/Developer/Xcode/DerivedData/ThemesDemo-gqxxcwvjavqbeeettltrpfsohmoe/Build/Intermediates/ThemesDemo.build/Debug-iphonesimulator/ThemesDemo.build/Objects-normal/i386/ThemesDemo_dependency_info.dat -o /Users/knetmac3/Library/Developer/Xcode/DerivedData/ThemesDemo-gqxxcwvjavqbeeettltrpfsohmoe/Build/Products/Debug-iphonesimulator/ThemesDemo.app/ThemesDemo
ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Hi,
Could somebody explain what's meant by this?
This is from the installation instruction. Does it mean to be done literally? I.e., via the 'Add files to project' function, and choose the xcodeproj file? I did this, which results in the UISS project now being inside my app's project (visually, in the project navigator pane). XCode appeared to compile the project, but when I add this: [UISS configureWithDefaultJSONFile];
, the UISS class is not found.
Whereas I used iOS 8.4 previously, now I am using iOS 9 GM Seed, and UISS is slowing down app startup significantly (by about 10-20 seconds). It looks like the main bottleneck exists in the many [NSInvocation invoke] calls when setting up UISS.
Would you consider reviewing a pull request to add support for osx styling?
UIImage *backButtonImage = [[UIImage imageNamed:@"NavigationBarBackButtonBackground"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 12.5, 0, 5)];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
I tried:
"backButtonBackgroundImage:normal":["NavigationBarBackButtonBackground", [0, 5, 0, 5]],
and
"backBackgroundImage:normal":["NavigationBarBackButtonBackground", [0, 5, 0, 5]],
but it's not working.
I'm planning to remove code generation feature.
I not sure anyone uses it and it slows the development of new UISS features quite a bit.
If you're using UISS please let me know what you think about this decision. Thanks.
Log:
objc[56776]: cannot form weak reference to instance (0xbfffd768) of class NSStackBlock
Line 112 of class UISSVariablesPreprocessor cause this crash.
__block __weak ResolveBlock resolveBlock = ^(NSString *n) {
if ([unresolved.allKeys containsObject:n]) {
id value = [unresolved objectForKey:n];
[unresolved removeObjectForKey:n];
[self setVariableValue:value forName:n withResolveBlock:resolveBlock];
}
return [weakSelf getValueForVariableWithName:n];
};
After remove __weak,the crash disapplear,but the compiler start to complain retain cycle.
Hi,
are there any plans to support UITraitCollection, i.e. appearanceForTraitCollection: and appearanceForTraitCollection:whenContainedInInstancesOfClasses: ?
Best regards,
Thomas
Hi, this library is incredible. It's pretty amazing to see it "just work".
My apps has two modes, and it needs to switch between two look-and-feels. It seems like having two stylesheets makes the most sense. But I'm not sure how to instruct the UI to refresh after switching.
Here's what I'm experimenting with: creating a new UISS instance, and then instructing it to refresh somehow. It's not refreshing, however:
self.uiss = [UISS configureWithURL:...
[self.uiss loadStyleSynchronously];
I found a bug when using the library. I can not use variables in the array construction.
Maybe I incorrect use this library?
Json file:
{
"Variables": {
"lightBlueColor": [[13, 107, 180, 1.0]],
},
"MyButton": {
"titleColor": [["$lightBlueColor", "normal"], ["white", "highlighted"]],
},
}
Error:
-[__NSArrayM intValue]: unrecognized selector sent to instance
File: UISSColorValueConverter.m, line 167
// red = [[array objectAtIndex:0] intValue] / 255.0f;
Reseting values back to default is a feature that would allow apps to change from any style back to default iOS style.
"UIButton": {
"image" : "/Users/knetmac3/Library/Application Support/iPhone Simulator/7.0.3/Applications/49EEBD4A-2ADC-485C-9764-D58475792F7F/myfiles/image1.png"
}
I want to do like this .. how i can ??
Just discoved UISS and its really great...
Is there any way to specify a class or Id to a object and then change its theme?
I have a UIButton subclass that has 2 status... if the status = 0 it has a grey background image and if its 1 it has a green background image and when I change the theme I want the status = 0 to use a red image and when 1 I want a blue image instead.
Is it possible to have something like:
{
"UIButton#Status0": {
"backgroundImage": "$img0"
},
"UIButton#Status1": {
"backgroundImage": "$img1"
}
}
Resulted in uncaught exception instead of graceful console reporting.
Styling a UINavigationBar changing any 'titleTextAttributes' won't auto reload the titlebar. Making a change to the 'tintColor' on 'UINavigationBar' will force a change and also apply any changes set to 'titleTextAttributes'.
Example uiss.json style file.
"UINavigationBar":{
"tintColor":"white",
"titleTextAttributes": {
"textColor": "#333333",
"textShadowOffset":[0,1],
"textShadowColor":"#eeeeee"
}
}
#ifdef DEBUG_UISS_INTERVAL
UISS *uiss = [[UISS alloc] init];
uiss.style.url = [NSURL URLWithString:@"http://localhost/uiss.json"];
[uiss load];
uiss.statusWindowEnabled = YES; // works when DEBUG_UISS_INTERVAL > 0
#if DEBUG_UISS_INTERVAL
[uiss enableAutoReloadWithTimeInterval:DEBUG_UISS_INTERVAL];
#endif
Well, I think the question is clear enough :), just in case I'm looking for something like.
// some themeing
"UITableViewHeaderFooterView": {
"tintColor": "$someTintColor",
"UILabel": {
"textColor": "$TextSubtitleColor",
"font": UIFontTextStyleCaption1
}
},
// some additional themeing
Is it possible to set a background image (or other image) from an external URL so that it's possible to update/change images on the fly as well without having to have them already be packaged in the app? If not, would there be a recommended way to do something like this - for example, download a new bundle from an external location and then use the bundle to set the image?
There are references to [UIApplication sharedApplication] and UIAlertView in the UISS iOS library, which is forbidden in (Today)App Extension context .It would be great if UISS can be used for app extensions. Can you please fix this by using a preprocessor macro?
This Feature would greatly simplify customization for Controls where only BackgroundImages can be set.
By specfiying only the Color UISS should generate the Image.
So Properties for Images would be easily customized.
In the UISS
class, queue
is defined as a nonatomic, assign
property.
When calling the loadStyleSynchronously
method, queue
isn't retained and a EXC_BAD_ACCESS
crash results.
The workaround is to declare the queue
property as strong
in line 30:
@property(nonatomic, strong) dispatch_queue_t queue; // all style parsing is done on the queue
Looks like the lib has an issue with the array subscript syntax used inside the NSArray+UISS category code. When you use this on iOS 5 it will crash with the following exception:
-[__NSArrayM objectAtIndexedSubscript:]: unrecognized selector sent to instance
From my research it look like that the back warts support for array subscription does not work from within a category.
I'm not sure if this lib is still supporting / or should be still supporting iOS 5 but from the pod file found in the example I expect that it does at the moment. So it would perhaps make sense to fix the code.
@implementation NSArray (UISS)
- (BOOL)canConvertToIntObjectAtIndex:(NSUInteger)index {
return self.count > index && [[self objectAtIndex:index] respondsToSelector:@selector(intValue)];
}
- (BOOL)canConvertToFloatObjectAtIndex:(NSUInteger)index {
return self.count > index && [[self objectAtIndex:index] respondsToSelector:@selector(floatValue)];
}
@end
Same Feature as in Issue #30 described. But the image should also be generated from gradient colors.
I am being able to modify components through properties, but I need to modify a UIBarItem with this method:
-(void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
I have not found any example that indicates how should the JSON look, and everything I have tried does not compile.
Thanks in advance
I need to change background of UITextField but doesn't work
"UITextField": {
"background":"txtField1"
}
How to set backgroundImage of UINavigationBar using UISS ??
i get the error 5704 "Unknown appearance class" on one of my viewControllers.
i have no clue why this happens... any hints?
Hi Robert,
Iām building an app that let the users share photos with football live scores over it, we have multiple score designs right now, iām styling using interfacebuilder .xib files, my current problem is that i have some sports teams that want to join with oficial skins packs, and we have to update the app everytime we want to add a new skins pack.
What we do right now is, we create an image 1080x1080 with the non dynamic items of each skin and then we position the dynamic elements in place using interfacebuilder.
I know that UISS can be used to style app UI/UX elements, my skin pack are 8 skins per pack, my specific question is :
Can i use UISS to create multiple UISS/Json to style (font-family,font-size, background-image, images-fields, position etc) each skin even from the server ?
Note: Dynamic items i get from a live scores api and are always the same , home_team , away_team, home_score, away_score, so i create a skin model with this items and just replicate
Thank you for your help
Currently compiling for iOS 7 generates warnings for deprecated API
Hi,
I'm having a problem getting button colours to work. Based on the demo project, I think I should be able to style buttons using titleColor:normal
, but it doesn't seem to work. I've put up an example at https://github.com/percysnoodle/uissbuttondemo - I'm using this UISS:
{
"UBDView" : {
"backgroundColor" : "#999999"
},
"UILabel" : {
"textAttributes" : {
"textColor" : "purple"
},
"backgroundColor" : "clear"
},
"UIButton" : {
"backgroundColor:normal" : "blue",
"backgroundColor:highlighted" : "red",
"titleColor:normal" : "yellow",
"titleColor:highlighted" : "green",
}
}
So I expect my buttons to be blue with yellow text. But what I see is this:
Am I using UISS wrongly, or is there an issue with button colours?
// I want to be able to get the value of variables.
// Create json file.
{
"Variables": {
"defaultBackgroundColor": "red"
},
"@Controllers": {
"MyViewController": {
"UITableView": {
"backgroundColor": "$defaultBackgroundColor"
}
},
}
}
// UISS init. And appearance is work.
UISS *uiss = [UISS configureWithDefaultJSONFile];
[UISS setSharedUISS:uiss];
// But sometimes I need write code
@implementation MyView
(void)drawRect:(CGRect)rect {
UIColor *color = [[UISS sharedUISS] colorForVariable:@"defaultBackgroundColor"];
UIBezierPath* bezier = [UIBezierPath bezierPath];
// ... my bezier code
[color setFill];
[bezier fill];
}
// Other UISS methods
Your sample code for (for example) -[UIColor colorWithRed:green:blue:alpha]
uses values up to 255.0f
but the maximum value for those methods is 1.0f
:
Sorry if this has been brought up before, didn't find anything.
Has a CSS like format been considered? We could probably absorb the parser used by NUI.
I find the JSON format a little messy and the variables aren't very elegant. JSON is always a good start, but I think something unique to UISS would be better for the future.
Thoughts?
UISS sounds like a great idea. Unfortunately, when I tried it, I had some immediate very simple problems with it. (iPad Simulator 7.0.3).
When I run the UISSDemo it looks like this:
There is obviously no Copperplate font in sight, though the JSON thinks, there should be:
"UISSDemoFirstViewController": {
"UIButton": {
"backgroundImage:normal": ["button-background-normal", [0,10,0,10]],
"backgroundImage:highlighted": ["button-background-highlighted", [0,10,0,10]],
"titleColor:normal": ["white", 0.8],
"titleColor:highlighted": "white",
"titleEdgeInsets": [1,0,0,0],
"UILabel": {
"font": ["Copperplate-Bold", 18]
}
}
}
Also it would be nice, if there is a JSON parser error, to get at least in DEBUG some sort of console output.
When i run the application on iOS 8 i found that this lines doesn't work.
"UITextField": {
"backgroundImage":"../textField_background"
}
"UIButton": {
"backgroundImage:normal":"../button_background",
"backgroundImage:highlighted":"../button_press_background"
}
"UINavigationBar": {
"backgroundImage:default": "../navigationBar_background"
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ššš
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ā¤ļø Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.