简体   繁体   English

xcode如何定义视图的高度和宽度

[英]xcode how to define the height and width of a view

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. 在这里,它的名称是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. 请注意,xPosition和yPosition是左上角,而不是中心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM