【发布时间】:2016-10-16 03:28:49
【问题描述】:
在UIScrollView 中添加了 10 个UIButtons。使用UIAnimation编写了自动滚动滚动视图的代码。
for (int i=0; i<10; i++) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(XPosition, YPosition, width,50);
[button setTitle:@"Warning animation items array " forState:UIControlStateNormal];
button.tag = i;
[button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
if (index%2) {
button.backgroundColor = [UIColor blueColor];
} else{
button.backgroundColor = [UIColor purpleColor];
}
XPosition = paddingSpace + XPosition + button.frame.size.width;
[_scroll addSubview:button];
index++;
}
_scroll.contentSize=CGSizeMake(XPosition,50);
为UIScrollView 设置动画时,我无法点击任何UIButton!!!
[UIView animateWithDuration:20
delay:0.0
options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat)
animations:^{
_scroll.contentOffset = CGPointMake(XPosition, 0.0);
} completion:^(BOOL finished){}];
如果动画只有停止,我可以点击UIButton。
请帮帮我。
【问题讨论】:
-
放上你的动画代码。
-
为什么可以使用带有 10 个按钮的滚动视图。您可以使用 tableview 并重用相同的按钮是一种更好的方法。分享你的代码
-
需要反复垂直滚动。滚动动画时我需要点击
标签: ios uiscrollview uibutton core-animation uianimation