开发者

xcode how to define the height and width of a view

开发者 https://www.devze.com 2023-03-04 06:17 出处:网络
HI everyone I\'m french so scuse me for my english SO here is my question: How can we define the height and the width of view. Here it name is flakeView. Here is the code :

HI everyone I'm french so scuse me for my english SO here is my question: How can we define the height and the width of view. Here it name is flakeView. Here is the code :

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


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

Note that xPosition and yPosition are the top left corner, not the center.

0

精彩评论

暂无评论...
验证码 换一张
取 消