IOS 奇妙的Code

收藏一些神奇的寫法和不錯的Code

LookInside/AAPLOverlayTransitioner.m
1
2
3
4
5

Class xyzClass;
xyzClass = [UIView class];
[[xyzClass alloc] init];

Lister/Commom/AAPLListColorUI.m
1
2
3
4
5
6
7
8

#if TARGET_OS_IPHONE
#define XColor UIColor
#elif TARGET_OS_MAC
#define XColor NSColor
#endif

XColor *grayColor = [XColor darkGrayColor];

CustomView

CustomView
1
2
3
4
5
6
7
8
9
10
11
12
13

- (void) setup{
NSString *nibName = NSStringFromClass([self class]);

//Bundle Identifier can be find at Target -> Your Framework -> Bundle Identifier
//NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.yume190.CustomViewObjc"];

UINib *nib = [UINib nibWithNibName:nibName bundle:[NSBundle mainBundle]];
[nib instantiateWithOwner:self options:nil];
//Add the view loaded from the nib into self.
[self addSubview:self.view];
}

CustomKeyboard

CustomKeyboard
1
2
3
4
5
6
7
8
9
10
11
12
13
14

@property (nonatomic, strong) UIView *customInterface;

-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
self = [super initWithNibName:nibNameOrNil bundle:nil];
if (self) {
//YumeKeyBoard.xib
UINib *nib = [UINib nibWithNibName:@"YumeKeyBoard" bundle:nil];
NSArray *objects = [nib instantiateWithOwner:self options:nil];
_customInterface = [objects firstObject];
}
return self;
}