我是iPhone的新程序员,也不是母语英语。我在绘图中感到困惑:rect。 问题是:当我有一个视图A和一个A的子视图B时,B的绘图:rect是: [(A *)self.superview draw:rect],然后我在A的draw中绘制一些字符串:rect。当我改变B的框架时,字符串被移动,所以如果它意味着字符串在子视图B中绘制? 谢谢你回答我的问题。 B类代码:
-(void)drawRect:(CGRect)rect
{
[(MyView *)self.superview drawMyRect:rect];
}
A类中的代码:
-(void)drawMyRect:(CGRect)rect
{
NSString *s = @"test view @_@";
[s drawInRect:rect withFont:[UIFont systemFontOfSize:15]];
}
- (void)layoutSubviews
{
CGRect b = CGRectMake(0, 0, 320, 480);
b.origin.x += _offsetRect.origin.x;
b.origin.y += _offsetRect.origin.y;
b.size.height -= _offsetRect.size.height;
b.size.width -= _offsetRect.size.width;
[_theSubView setFrame:b];
[_theSubView setNeedsDisplay];
_offsetRect = CGRectZero;
[super layoutSubviews];
}