【问题标题】:xcode how to define the height and width of a viewxcode如何定义视图的高度和宽度
【发布时间】:2011-08-21 23:26:34
【问题描述】:

大家好,我是法国人,所以请原谅我的英语,所以这是我的问题:我们如何定义视图的高度和宽度。这里它的名字是 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;
                 }];

【问题讨论】:

    标签: iphone uiimageview height width


    【解决方案1】:
    CGRect frame = CGRectMake(xPosition, yPosition, width, height);
    flakeView.frame = frame;
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-03
      • 2011-05-03
      • 2011-12-08
      • 1970-01-01
      • 1970-01-01
      • 2017-01-20
      • 2012-08-27
      相关资源
      最近更新 更多