{"id":13743038,"url":"https://github.com/robertwijas/UISS","last_synced_at":"2025-05-09T00:32:33.395Z","repository":{"id":56925019,"uuid":"2533836","full_name":"robertwijas/UISS","owner":"robertwijas","description":"UIAppearance Stylesheets","archived":true,"fork":false,"pushed_at":"2017-07-05T20:30:27.000Z","size":2362,"stargazers_count":1230,"open_issues_count":21,"forks_count":81,"subscribers_count":59,"default_branch":"master","last_synced_at":"2025-03-20T17:41:55.907Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertwijas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-10-07T16:53:01.000Z","updated_at":"2025-01-17T15:58:48.000Z","dependencies_parsed_at":"2022-08-21T06:20:06.751Z","dependency_job_id":null,"html_url":"https://github.com/robertwijas/UISS","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertwijas%2FUISS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertwijas%2FUISS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertwijas%2FUISS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertwijas%2FUISS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertwijas","download_url":"https://codeload.github.com/robertwijas/UISS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253171162,"owners_count":21865275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T05:00:39.220Z","updated_at":"2025-05-09T00:32:32.776Z","avatar_url":"https://github.com/robertwijas.png","language":"Objective-C","funding_links":[],"categories":["Objective-C  Stars 1000以内排名整理","Objective-C","etc"],"sub_categories":[],"readme":"[Subscribe to UISS mailing list.](http://eepurl.com/bnNaq1)\n\n# What is UISS?\n\nUISS stands for UIKit Style Sheets.\n\nUISS is an iOS library that provides you with a convenient way to define the style of your application.\nUISS is built on top of UIKit UIAppearance proxies.\n\n# What UISS can do for you?\n\nUISS has the power to:\n\n* replace unreadable UIAppearance code with a simple JSON dictionary,\n* provide a way to change application style without the need to rebuild your code, without the need to restart your app, even without the need to reload your views - yep, this is *the sexy* feature of UISS.\n\n# Design goal\n\nUISS do not enforce any dependencies on your app. You can generate Objective-C code for your UISS style so you do not even have to link with UISS library in your production build.\n\n# But how does it really look?\n\nAssuming you're familiar with UIAppearance proxy you probably wrote a piece of code similar to this one:\n\n```objc\n[[UITabBar appearance] setTintColor:[UIColor darkGrayColor]]\n```\n\nin UISS it looks like this:\n\n```json\n{\n    \"UITabBar\": {\n        \"tintColor\": \"darkGray\",\n    }\n}\n```\n\nno big difference here, so lets look at more complex example:\n\n```objc\n[[UIButton appearance] setTitleColor:[[UIColor whiteColor] colorWithAlphaComponent:0.800]\n                            forState:UIControlStateNormal];\n[[UIButton appearance] setTitleColor:[UIColor whiteColor]\n                            forState:UIControlStateHighlighted];\n[[UIButton appearance] setBackgroundImage:[[UIImage imageNamed:@\"button-background-normal\"]\n              resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 10.0, 0.0, 10.0)]\n                                 forState:UIControlStateNormal];\n[[UIButton appearance] setBackgroundImage:[[UIImage imageNamed:@\"button-background-highlighted\"]\n              resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 10.0, 0.0, 10.0)]\n                                 forState:UIControlStateHighlighted];\n[[UILabel appearanceWhenContainedIn:[UIButton class], nil] setFont:[UIFont fontWithName:@\"Copperplate-Bold\" size:18.0]];\n[[UIButton appearance] setTitleEdgeInsets:UIEdgeInsetsMake(1.0, 0.0, 0.0, 0.0)];\n```\n\n```json\n{\n\t\"UIButton\":{\n\t    \"titleColor:normal\":[\"white\", 0.8],\n\t    \"titleColor:highlighted\":\"white\",\n\t    \"backgroundImage:normal\": [\"button-background-normal\", [0,10,0,10]],\n\t    \"backgroundImage:highlighted\": [\"button-background-highlighted\", [0,10,0,10]],\n\t    \"titleEdgeInsets\": [1,0,0,0],\n\t    \"UILabel\":{\n\t        \"font\":[\"Copperplate-Bold\", 18]\n\t    }\n\t}\n}\n```\n\n# Install\n\n* get the code\n* add UISS.xcodeproj to your project\n* (optional) add UISSResource.bundle to your target\n\n## Configure UISS\n\n### Local\n\nThe simplest way to start with UISS is to create `uiss.json` file and add it to your project's resources. To activate this file add this line:\n\n```objc\n[UISS configureWithDefaultJSONFile];\n```\n\nThis should be called before your views are displayed, the common place for that is your Application Delegate's _didFinishLaunching_ method.\n\n### Remote\n\nIf you want to load your style from remote location to enable live updates, here's how to do that:\n\n\tself.uiss = [UISS configureWithURL:[NSURL URLWithString:@\"http://localhost/uiss.json\"]];\n\n### Live updates\n\nUISS can detect if your style changed and automatically update your interface. To enable this feature call this method:\n\n```objc\nuiss.autoReloadEnabled = YES;\nuiss.autoReloadTimeInterval = 1;\n```\n\n### Status bar\n\n```objc\nuiss.statusWindowEnabled = YES;\n```\n\nUISS will take a small portion of the screen (usually taken by status bar) to show you what is going on behind the scenes.\n\n### Console\n\nTapping on UISS status bar will present console view where:\n\n* you can get info about errors in your style\n* you can generate UIAppearance code for your style\n\n# Syntax\n\n## Axis parameters\n\n## Containment\n\n## Converters\n\nUISS has value converters for every type used to set _UIAppearance_ properties. These converters provide useful shortcuts and convinient syntax for defining your properties.\n\nHere are some examples and eqivalent values in _Objective-C_ code.\n\n### Colors\n\n#### Hex\n\n```json\n\"#ffffff\"\n```\n```objc\n[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1]\n````\n\n#### Default UIColor colors\n\n```json\n\"red\"\n```\n```objc\n[UIColor redColor]\n````\n```json\n\"redColor\"\n```\n```objc\n[UIColor redColor]\n````\n\n#### Colors with pattern image\n\n```json\n\"patternImageName\"\n```\n```objc\n[UIColor colorWithPatternImage:@\"patternImageName\"]\n````\n\n#### RGB\n\n```json\n[0, 255, 255]\n```\n```objc\n[UIColor colorWithRed:0.0f green:1.0f blue:1.0f alpha:1.0f]\n````\n\n#### Colors with alpha\n\n```json\n[\"#ffffff\", 0.5]\n```\n```objc\n[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:.0.5f]\n````\n```json\n[\"red\", 0.5]\n```\n```objc\n[[UIColor redColor] colorWithAlphaComponent:0.5f]\n````\n```json\n[0, 255, 255, 0.5]\n```\n```objc\n[UIColor colorWithRed:0.0f green:1.0f blue:1.0f alpha:.0.5f]\n````\n\n### Images\n\n#### Simple image with name:\n\n```json\n\"imageName\"\n```\n```objc\n[UIImage imageNamed:@\"imageName\"]\n````\n\n#### Resizable images:\n\n```json\n[\"imageName\", 1, 2, 3, 4]\n```\n```objc\n[[UIImage imageNamed:@\"imageName\"] resizableImageWithCapInsets:UIEdgeInsetsMake(1, 2, 3, 4)]\n````\n\n### Fonts\n\n```json\n14\n```\n```objc\n[UIFont systemFontOfSize:14.0f]\n````\n```json\n[\"bold\", 14]\n```\n```objc\n[UIFont boldSystemFontOfSize:14.0f]\n````\n```json\n[\"italic\", 20]\n```\n```objc\n[UIFont italicSystemFontOfSize:14.0f]\n````\n```json\n[\"Georgia-Italic\", 12]\n```\n```objc\n[UIFont fontWithName:@\"Georgia-Italic\" size:12.0f]\n````\n\n### TextAttributes\n\n```json\n{\n\t\"font\": [\"bold\", 12],\n\t\"textColor\": \"black\",\n\t\"textShadowColor\": \"lightGray\",\n\t\"textShadowOffset\": [1, 2]\n}\n```\n```objc\n[NSDictionary dictionaryWithObjectsAndKeys:\n [UIFont boldSystemFontOfSize:12], UITextAttributeFont,\n [UIColor blackColor], UITextAttributeTextColor,\n [UIColor lightGrayColor], UITextAttributeTextShadowColor,\n [NSValue valueWithUIOffset:UIOffsetMake(1, 2)], UITextAttributeTextShadowOffset, nil];\n````\n\n### Structures\n\n#### CGSize\n\n| JSON | Objective-C |\n-------|--------------\n| ```1``` | ```CGSizeMake(1, 1)``` |\n| ```[1]``` | ```CGSizeMake(1, 1)``` |\n| ```[1, 2]``` | ```CGSizeMake(1, 2)``` |\n\n\n#### CGRect\n\n| JSON | Objective-C |\n-------|--------------\n| ```[1, 2, 3, 4]``` | ```CGRectMake(1, 2, 3, 4)``` |\n\n#### UIEdgeInsets\n\n| JSON | Objective-C |\n-------|--------------\n| ```[1, 2, 3, 4]``` | ```UIEdgeInsetsMake(1, 2, 3, 4)``` |\n\n#### UIOffset\n\n| JSON | Objective-C |\n-------|--------------\n| ```1``` | ```UIOffsetMake(1, 1)``` |\n| ```[1]``` | ```UIOffsetMake(1, 1)``` |\n| ```[1, 2]``` | ```UIOffsetMake(1, 2)``` |\n\n#### CGPoint\n\n| JSON | Objective-C |\n-------|--------------\n| ```1``` | ```CGPointMake(1, 1)``` |\n| ```[1]``` | ```CGPointMake(1, 1)``` |\n| ```[1, 2]``` | ```CGPointMake(1, 2)``` |\n\n### UIKit Enums\n\n#### UIBarMetrics\n\n| JSON | Objective-C |\n-------|--------------\n| ```default``` | ```UIBarMetricsDefault``` |\n| ```landscapePhone``` | ```UIBarMetricsLandscapePhone``` |\n\n#### UIControlState\n\n| JSON | Objective-C |\n-------|--------------\n| ```normal``` | ```UIControlStateNormal``` |\n| ```highlighted``` | ```UIControlStateHighlighted``` |\n| ```disabled``` | ```UIControlStateDisabled``` |\n| ```selected``` | ```UIControlStateSelected``` |\n| ```reserved``` | ```UIControlStateReserved``` |\n| ```application``` | ```UIControlStateApplication``` |\n\n#### UISegmentedControlSegment\n\n| JSON | Objective-C |\n-------|--------------\n| ```any``` | ```UISegmentedControlSegmentAny``` |\n| ```left``` | ```UISegmentedControlSegmentLeft``` |\n| ```center``` | ```UISegmentedControlSegmentCenter``` |\n| ```right``` | ```UISegmentedControlSegmentRight``` |\n| ```alone``` | ```UISegmentedControlSegmentAlone``` |\n\n#### UIToolbarPosition\n\n| JSON | Objective-C |\n-------|--------------\n| ```any``` | ```UIToolbarPositionAny``` |\n| ```bottom``` | ```UIToolbarPositionBottom``` |\n| ```top``` | ```UIToolbarPositionTop``` |\n\n#### UISearchBarIcon\n\n| JSON | Objective-C |\n-------|--------------\n| ```search``` | ```UISearchBarIconSearch``` |\n| ```clear``` | ```UISearchBarIconClear``` |\n| ```bookmark``` | ```UISearchBarIconBookmark``` |\n| ```resultsList``` | ```UISearchBarIconResultsList``` |\n\n## Variables\n\nYou can define variables that can be used in your UISS style. All variables shoud be defined under _Variables_ key in your style dictionary. To reference a variable prefix its name with _$_ sign.\n\nExample:\n\n```json\n{\n\t\"Variables\": {\n\t\t\"tintColor\": \"red\"\n\t},\n\n\t\"UIToolbar\": {\n\t\t\"tintColor\": \"$tintColor\"\n\t}\n}\n```\n\n## User Interface Idioms\n\nSometimes you want to have a slightly different look on the iPhone from the one you have on the iPad.\nWith UISS you can create parts of style that apply only to a specified UI Idiom.\n\n```json\n{\n\t\"UINavigationBar\": {\n\t    \"Phone\": {\n\t        \"tintColor\": \"gray\"\n\t    },\n\t    \"Pad\": {\n\t        \"tintColor\": \"lightGray\"\n\t    }\n\t}\n}\n```\n\n## Comments\n\nJSON specification doesn't support comments. But sometimes being able to easly disable some parts of your UISS style can be really useful. You can do that by adding ```-``` prefix to dictionary keys. UISS will ignore those keys without reporting errors.\n\nExample:\n\n```json\n{\n\t\"UIToolbar\": {\n\t\t\"-tintColor\": \"blue\",\n\t\t\"backgroundImage:any:default\": \"background\"\n\t},\n\t\"-UITabbar\": {\n\t\t\"tintColor\": \"blue\"\n\t}\n}\n```\n\nThis will only set _UIToolbar's_ background image.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertwijas%2FUISS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertwijas%2FUISS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertwijas%2FUISS/lists"}