大家好我是法国人,所以请原谅我的英语。所以这是我的问题:我们如何定义视图的高度和宽度。这里它的名字是flakeView。这是代码:
UIImageView* flakeView = [[[UIImageView alloc] initWithImage:flakeImage] autorelease];
// use the random() function to randomize up our flake attributes
int startY = round(random() % 320);
// set the flake start position
flakeView.center = CGPointMake(490, startY);
flakeView.alpha = 1;
// put the flake in our main view
[self.view addSubview:flakeView];
[UIView animateWithDuration:7
animations:^{
// set the postion where flake will move to
flakeView.center = viewToRotate.center;
}];
答案 0 :(得分:7)
CGRect frame = CGRectMake(xPosition, yPosition, width, height);
flakeView.frame = frame;
请注意,xPosition和yPosition是左上角,而不是中心。