我想做一个简单的方法来记录视图的框架,但也记录特定视图输入的名称。除了输入字符串作为方法的参数之外,是否有一种简单的方法可以获得与被调用视图等效的字符串?
-(void)printViewFrame:(UIView*)view {
NSLog(@"%@'s frame is: origin x: %f, origin y: %f, size x: %f, size y: %f", view ,view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
}
[self printViewFrame:myView];
注意:现在我只是这样做,这有点难看:
-(void)printViewFrame:(UIView*)view name:(NSString*)name {
NSLog(@"%@'s frame: %@",name, NSStringFromCGRect(view.frame));
}