From d9efab314e3b610190956c1588abc830907d0534 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 14 Jun 2013 04:02:52 +0900 Subject: [PATCH] UI7Switch partial implementations --- UI7Kit.xcodeproj/project.pbxproj | 6 +++ UI7Kit/UI7Button.h | 2 +- UI7Kit/UI7Button.m | 2 +- UI7Kit/UI7Kit.m | 3 +- UI7Kit/UI7Switch.h | 13 ++++++ UI7Kit/UI7Switch.m | 61 +++++++++++++++++++++++++++++ UI7Kit/UI7TableView.m | 8 ++-- UI7KitTestApp/Storyboard.storyboard | 35 +++++++++++++---- UI7KitTests/UI7KitTests.h | 2 +- UI7KitTests/UI7KitTests.m | 2 +- 10 files changed, 118 insertions(+), 16 deletions(-) create mode 100644 UI7Kit/UI7Switch.h create mode 100644 UI7Kit/UI7Switch.m diff --git a/UI7Kit.xcodeproj/project.pbxproj b/UI7Kit.xcodeproj/project.pbxproj index fba593e..562146e 100644 --- a/UI7Kit.xcodeproj/project.pbxproj +++ b/UI7Kit.xcodeproj/project.pbxproj @@ -38,6 +38,7 @@ 38AF86CF1769BC8000BFBD29 /* libUI7Kit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 38017423176989650049D26C /* libUI7Kit.a */; }; 38BC0E5D173E821700F36497 /* UITSubviewTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 38BC0E5B173E821700F36497 /* UITSubviewTableViewController.m */; }; 38EEF9C7176A366C0085B09B /* UI7Button.m in Sources */ = {isa = PBXBuildFile; fileRef = 38EEF9C6176A366C0085B09B /* UI7Button.m */; }; + 38EEF9CA176A482C0085B09B /* UI7Switch.m in Sources */ = {isa = PBXBuildFile; fileRef = 38EEF9C9176A482C0085B09B /* UI7Switch.m */; }; 38F068181636F8C8002723AB /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 383764E213373155007072FD /* UIKit.framework */; }; 38F068191636F8C8002723AB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 383764D713373154007072FD /* Foundation.framework */; }; 38F0681A1636F8C8002723AB /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 383764E513373155007072FD /* CoreGraphics.framework */; }; @@ -131,6 +132,8 @@ 38E58A901767576300F6ED19 /* UI7Kit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UI7Kit.h; sourceTree = ""; }; 38EEF9C5176A366C0085B09B /* UI7Button.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UI7Button.h; sourceTree = ""; }; 38EEF9C6176A366C0085B09B /* UI7Button.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UI7Button.m; sourceTree = ""; }; + 38EEF9C8176A482C0085B09B /* UI7Switch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UI7Switch.h; sourceTree = ""; }; + 38EEF9C9176A482C0085B09B /* UI7Switch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UI7Switch.m; sourceTree = ""; }; 38F068161636F8C8002723AB /* UI7KitTestApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UI7KitTestApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38F0681D1636F8C8002723AB /* UI7KitTestApp-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UI7KitTestApp-Info.plist"; sourceTree = ""; }; 38F0681F1636F8C8002723AB /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -304,6 +307,8 @@ 382F54281767863B004D6F59 /* UI7TableView.m */, 38EEF9C5176A366C0085B09B /* UI7Button.h */, 38EEF9C6176A366C0085B09B /* UI7Button.m */, + 38EEF9C8176A482C0085B09B /* UI7Switch.h */, + 38EEF9C9176A482C0085B09B /* UI7Switch.m */, 380174601769FE390049D26C /* Resources */, 38017426176989660049D26C /* Supporting Files */, ); @@ -517,6 +522,7 @@ 38EEF9C7176A366C0085B09B /* UI7Button.m in Sources */, 3801744F176989B80049D26C /* UI7Kit.m in Sources */, 38017450176989B80049D26C /* UI7Utilities.m in Sources */, + 38EEF9CA176A482C0085B09B /* UI7Switch.m in Sources */, 38017451176989B80049D26C /* UI7NavigationBar.m in Sources */, 38017452176989B80049D26C /* UI7Toolbar.m in Sources */, 38017453176989B80049D26C /* UI7BarButtonItem.m in Sources */, diff --git a/UI7Kit/UI7Button.h b/UI7Kit/UI7Button.h index 18fb06f..a812695 100644 --- a/UI7Kit/UI7Button.h +++ b/UI7Kit/UI7Button.h @@ -3,7 +3,7 @@ // UI7Kit // // Created by Jeong YunWon on 13. 6. 14.. -// Copyright (c) 2013년 youknowone.org. All rights reserved. +// Copyright (c) 2013 youknowone.org. All rights reserved. // #include diff --git a/UI7Kit/UI7Button.m b/UI7Kit/UI7Button.m index cbcb373..bbb5a8f 100644 --- a/UI7Kit/UI7Button.m +++ b/UI7Kit/UI7Button.m @@ -3,7 +3,7 @@ // UI7Kit // // Created by Jeong YunWon on 13. 6. 14.. -// Copyright (c) 2013년 youknowone.org. All rights reserved. +// Copyright (c) 2013 youknowone.org. All rights reserved. // #import "UI7Button.h" diff --git a/UI7Kit/UI7Kit.m b/UI7Kit/UI7Kit.m index 70e8f7f..1ee0cba 100644 --- a/UI7Kit/UI7Kit.m +++ b/UI7Kit/UI7Kit.m @@ -3,7 +3,7 @@ // UI7Kit // // Created by Jeong YunWon on 13. 6. 13.. -// Copyright (c) 2013년 youknowone.org. All rights reserved. +// Copyright (c) 2013 youknowone.org. All rights reserved. // #import "UI7Kit.h" @@ -18,6 +18,7 @@ void UI7KitPatchAll(BOOL override7) { @"UI7NavigationBar", @"UI7NavigationController", @"UI7Button", + @"UI7Switch", ]) { Class class = NSClassFromString(className); [class patch]; diff --git a/UI7Kit/UI7Switch.h b/UI7Kit/UI7Switch.h new file mode 100644 index 0000000..29f6fba --- /dev/null +++ b/UI7Kit/UI7Switch.h @@ -0,0 +1,13 @@ +// +// UI7Switch.h +// UI7Kit +// +// Created by Jeong YunWon on 13. 6. 14.. +// Copyright (c) 2013 youknowone.org. All rights reserved. +// + +#import + +@interface UI7Switch : UISwitch + +@end diff --git a/UI7Kit/UI7Switch.m b/UI7Kit/UI7Switch.m new file mode 100644 index 0000000..aebe30c --- /dev/null +++ b/UI7Kit/UI7Switch.m @@ -0,0 +1,61 @@ +// +// UI7Switch.m +// UI7Kit +// +// Created by Jeong YunWon on 13. 6. 14.. +// Copyright (c) 2013 youknowone.org. All rights reserved. +// + +#import "UI7Switch.h" + +@implementation UISwitch (Patch) + +- (id)__initWithCoder:(NSCoder *)aDecoder { assert(NO); return nil; } +- (id)__initWithFrame:(CGRect)frame { assert(NO); return nil; } + +- (void)_switchInit { + self.onTintColor = [UIColor colorWith8bitRed:76 green:217 blue:100 alpha:255]; + if ([self respondsToSelector:@selector(onImage)]) { + self.onImage = [UIImage blankImage]; + self.offImage = [UIImage blankImage]; + } +} + +@end + +@implementation UI7Switch + ++ (void)initialize { + if (self == [UI7Switch class]) { + NSAClass *class = [NSAClass classWithClass:[UISwitch class]]; + [class copyToSelector:@selector(__initWithCoder:) fromSelector:@selector(initWithCoder:)]; + [class copyToSelector:@selector(__initWithFrame:) fromSelector:@selector(initWithFrame:)]; + } +} + ++ (void)patch { + NSAClass *sourceClass = [NSAClass classWithClass:[self class]]; + Class targetClass = [UISwitch class]; + + [sourceClass exportSelector:@selector(initWithCoder:) toClass:targetClass]; + [sourceClass exportSelector:@selector(initWithFrame:) toClass:targetClass]; +} + +- (id)initWithCoder:(NSCoder *)aDecoder { + self = [super __initWithCoder:aDecoder]; + if (self != nil) { + [self _switchInit]; + } + return self; +} + +- (id)initWithFrame:(CGRect)frame +{ + self = [self __initWithFrame:frame]; + if (self != nil) { + [self _switchInit]; + } + return self; +} + +@end diff --git a/UI7Kit/UI7TableView.m b/UI7Kit/UI7TableView.m index e6bbf6b..504497f 100644 --- a/UI7Kit/UI7TableView.m +++ b/UI7Kit/UI7TableView.m @@ -38,10 +38,10 @@ + (void)initialize { + (void)patch { NSAClass *sourceClass = [NSAClass classWithClass:[self class]]; - - [sourceClass exportSelector:@selector(initWithCoder:) toClass:[UITableView class]]; - [sourceClass exportSelector:@selector(initWithFrame:) toClass:[UITableView class]]; - [sourceClass exportSelector:@selector(setDelegate:) toClass:[UITableView class]]; + Class targetClass = [UITableView class]; + [sourceClass exportSelector:@selector(initWithCoder:) toClass:targetClass]; + [sourceClass exportSelector:@selector(initWithFrame:) toClass:targetClass]; + [sourceClass exportSelector:@selector(setDelegate:) toClass:targetClass]; } - (id)initWithCoder:(NSCoder *)aDecoder { diff --git a/UI7KitTestApp/Storyboard.storyboard b/UI7KitTestApp/Storyboard.storyboard index 865c87c..0430de8 100644 --- a/UI7KitTestApp/Storyboard.storyboard +++ b/UI7KitTestApp/Storyboard.storyboard @@ -1,16 +1,15 @@ - + - + - + - @@ -85,7 +84,6 @@ - @@ -128,7 +126,6 @@ - @@ -184,7 +181,6 @@ - @@ -192,6 +188,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/UI7KitTests/UI7KitTests.h b/UI7KitTests/UI7KitTests.h index 5c3d2e1..f8c6dc6 100644 --- a/UI7KitTests/UI7KitTests.h +++ b/UI7KitTests/UI7KitTests.h @@ -3,7 +3,7 @@ // UI7KitTests // // Created by Jeong YunWon on 13. 6. 13.. -// Copyright (c) 2013년 youknowone.org. All rights reserved. +// Copyright (c) 2013 youknowone.org. All rights reserved. // #import diff --git a/UI7KitTests/UI7KitTests.m b/UI7KitTests/UI7KitTests.m index 593867b..2c9a9c0 100644 --- a/UI7KitTests/UI7KitTests.m +++ b/UI7KitTests/UI7KitTests.m @@ -3,7 +3,7 @@ // UI7KitTests // // Created by Jeong YunWon on 13. 6. 13.. -// Copyright (c) 2013년 youknowone.org. All rights reserved. +// Copyright (c) 2013 youknowone.org. All rights reserved. // #import "UI7KitTests.h"