0

目前,我在我的應用程序這個功能,我實現一個UIScrollView是在高度很瘦,但長,寬...的UIScrollView重疊MAINVIEW內容

Hourly Forecast

正如你所看到的,UIScrollView中正在重疊backgroundview ...並非白色背景是UIScrollView作爲SUBVIEW添加到的UIView。

問題是,當UIScrollView剛剛添加到子視圖中時,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到的UIView(whitebackground視圖),其名稱是ForecastView:

_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]; 

回答

3

默認,視圖不會剪裁它的子視圖。爲了使剪裁,設置了UIView clipsToBounds財產,或

enter image description here

(信貸Mugunth的圖像)設置在Interface Builder

+0

AHH你是個天才!謝謝@Turch !!! – jsetting32