2011-05-09 73 views
1

嗨,大家好,我是法国人,所以我嘲笑我的英语这里是我的问题:我们如何定义视图的高度和宽度。这里它的名字是flakeView。下面是代码:xcode如何定义视图的高度和宽度

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; 
       }]; 

回答

7
CGRect frame = CGRectMake(xPosition, yPosition, width, height); 
flakeView.frame = frame; 

注意的xPosition和yPosition是左上角,不是中心。

相关问题