获取类名

[NSString stringWithUTF8String:object_getClassName(a)];

我们可以通过上述语句获取这个对象的所属类名。

例子:我们可以用到上述方法来获取keyBoard,改变keyBoard 的颜色,但是注意只有以下两种数字键盘才有效果:UIKeyboardTypeNumberPad,UIKeyboardTypePhonePad

2. keyboardAppearance = UIKeyboardAppearanceAlert

- (void)textViewDidBeginEditing:(UITextView *)textView{
NSArray *ws = [[UIApplication sharedApplication] windows];
for(UIView *w in ws){
NSArray *vs = [w subviews];
for(UIView *v in vs){
if([[NSString stringWithUTF8String:object_getClassName(v)] isEqualToString:@”UIKeyboard”]){
v.backgroundColor = [UIColor redColor];
}
}
}

posted @ 2015-11-24 10:18  guangleijia  阅读(135)  评论(0编辑  收藏  举报