获取类名
[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];
}
}
}