2
我有4個標籤框,我有一個UIscrollview,我有4頁。如果我們滾動滾動視圖手動(通過拖動)標籤框的顏色必須根據頁碼進行更改。 任何命中做到這一點。如果我們滾動滾動視圖,改變標籤框的顏色
UIScrollView *scroll = [[UIScrollView alloc]initWithFrame: CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height)];
scroll.pagingEnabled = YES;
NSInteger numberOfViews = 4;
float j=0;
for (int i = 0; i < numberOfViews; i++) {
CGFloat yOrigin = i * self.view.frame.size.width;
printf("%f\n",yOrigin);
UIView *scrollview = [[UIView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)];
scrollview.backgroundColor = [UIColor cyanColor];
[scroll addSubview:scrollview];
[scrollview release];
j=j+0.2;
}
這是天才,謝謝! – Dvole 2013-08-25 14:03:52