我不明白如何才能将UIView添加到第二个UIView中,从第二个UIView的中心开始,而不是从左上角开始,我举了一个例子:我想将一个UIView添加到这个CGPoint:(-96,96),第二个UIView是一个300x300的正方形,所以我想从中心开始添加UIView,而UIVIew是从左上角开始添加的,当它被添加到屏幕之外时,这是一个示例:
________________
| |
y | x |
| . |
| |
| |
|______________|
x = where i want should go the UIView
y = where instead it's added我怎么才能修复它?
编辑:我这样添加UIView:
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 70)];
v.center = CGPointMake(-96,96);
[self.squareView addSubview:v];发布于 2015-07-26 17:30:15
试试这个:
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 70)];
v.center = squareView.center;
var frame:CGRect = v.frame
frame.origin.x -= 96
frame.origin.y += 96
v.frame = frame
[self.squareView addSubview:v];https://stackoverflow.com/questions/31635374
复制相似问题