【问题标题】:how to make UIView subview a fixed size programmatically如何以编程方式使 UIView 子视图固定大小
【发布时间】:2010-11-02 01:45:32
【问题描述】:

我有一个 UIView 子类,我希望它是 50x50;当我加载它时,它总是占据整个屏幕我该如何解决这个问题?

【问题讨论】:

    标签: ipad ios


    【解决方案1】:

    发布一些代码可以帮助我们帮助您,但这里是您设置任何 UIView 子类的框架的方法:

    // When creating the view...
    UIView *yourView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    
    // or after having created the view...
    yourView.frame = CGRectMake(0, 0, 50, 50);
    // ... or
    [yourView setFrame:CGRectMake(0, 0, 50, 50)];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-06
      • 1970-01-01
      • 2019-03-07
      • 2015-06-08
      • 2011-02-27
      • 2010-10-08
      • 1970-01-01
      相关资源
      最近更新 更多