This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 208
/
UI7Switch.m
61 lines (49 loc) · 1.54 KB
/
UI7Switch.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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