目前,我在我的应用程序中有这个功能,在那里我实现了一个高度很薄但宽度很长的 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];