【发布时间】:2011-06-19 14:19:34
【问题描述】:
我想画一个矩形,可以实时改变矩形的位置和大小。
我尝试了以下两种方法,但视图不显示矩形。
你有什么建议或例子吗?
感谢您的帮助。
使用视图框架(它只在重新启动应用时显示新的矩形)
UIView * drawView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 10, 10)];
[self.view addSubview:drawView];
drawView.layer.borderColor = [[UIColor orangeColor] CGColor];
drawView.layer.borderWidth = 2;
drawView.frame = CGRectMake(r.x, r.y, r.width, r.height);
在drawRect中绘制
fav = [[FaceAugmentingView alloc] initWithFrame:[imageView frame]];
fav.backgroundColor = [UIColor clearColor];
[self.view addSubview: fav ];
fav.face = CGRectMake(r.x, r.y, r.width, r.height);
[fav setNeedsDisplay];
【问题讨论】:
-
如果您不告诉我们您使用的是哪种语言/开发环境,我们无能为力。
-
它被标记为 iphone - 这意味着 大多数 情况下是 Xcode/Objective-C/Cocoa-Touch。
标签: iphone objective-c xcode real-time