【问题标题】:UIScrollview overlapping mainview contentUIScrollview 重叠主视图内容
【发布时间】:2013-06-27 17:51:00
【问题描述】:

目前,我的应用程序中有这个功能,我在其中实现了一个高度很薄但宽度很长的 UIScrollview...

如您所见,UIScrollView 与 backgroundview 重叠...不是白色背景是 UIView,我将 UIScrollView 作为 SUBVIEW 添加到其中。

问题是,UIScrollView 刚刚添加到子视图时,它是如何与黑色背景内容重叠的?

这是我的 UIScrollView 的 init 方法。

self = [super init];
if (self) {
    self.frame = CGRectMake(0, 0, 280, 70);
    self.contentSize = CGSizeMake(480, 70);
    self.showsHorizontalScrollIndicator = NO;
    self.bounces = NO;
}

下面是我如何将 UIScrollView 添加到名称为 ForecastView 的 UIView(白色背景视图)中:

_hourlyForecast = [[hourlyForecastScrollView alloc] init:_city state:_state icons:_icons times:_times temps:_temps];
_hourlyForecast.backgroundColor = [UIColor blueColor];
_hourlyForecast.frame = CGRectMake(20, 20, self.ForecastView.bounds.size.width, 70);
[_ForecastView addSubview:_hourlyForecast];

【问题讨论】:

    标签: uiview uiscrollview subview uiscrollviewdelegate layoutsubviews


    【解决方案1】:

    默认情况下,视图不会剪切它的子视图。要启用剪辑,请设置 UIView clipsToBounds 属性,或在 Interface Builder 中设置

    (图片归功于Mugunth

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-23
      • 1970-01-01
      • 2018-01-21
      • 1970-01-01
      • 2017-05-25
      • 1970-01-01
      • 2019-07-07
      • 1970-01-01
      相关资源
      最近更新 更多