答案 0 :(得分:1)
使用图库视图对象。只需用想要水平滚动的图像填充它。 这将很好地接近你想要实现的目标。
答案 1 :(得分:1)
查看我的视频 http://www.youtube.com/watch?v=4acFshAlGJ8
我有用 https://lh3.googleusercontent.com/-WZEDMSmfrK0/TeeD93t8qYI/AAAAAAAAAKw/X9D6jRkLfLk/s800/MUKScale.png 在scrollView中将图像作为缩放图像这是一个不完整的示例,只是为了说明它是如何实现的。
这是一些有用的代码, 在这里,一切都是静态的,但对于真正的工作,人们应该更多地工作,
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:scrollView];
UIImageView *backImgg = [[UIImageView alloc] initWithFrame:CGRectMake(x,y,886,15)];
[backImgg setImage: [UIImage imageNamed:@"MUKScale.png"]];//Image in the link above
[scrollView addSubview:backImgg];
[backImgg release];
[scrollView setContentSize:CGSizeMake(886,15)];
return;
}
NSTimer *timer ;
float timeSet =0 ;
-(IBAction) btnPressed
{
timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(showTimeInLbl) userInfo:nil repeats:YES];
}
-(void)showTimeInLbl
{
CGRect visibleRect;
visibleRect.origin = scrollView.contentOffset;
visibleRect.size = scrollView.contentSize;
NSLog( @"Visible rect: %@", NSStringFromCGRect(visibleRect) );
float time = visibleRect.origin.x / 8;
timeSet = time;
lblTime.text = [NSString stringWithFormat:@"%f",time];
[UIView animateWithDuration: .1
animations: ^{
[scrollView setContentOffset:CGPointMake(visibleRect.origin.x - 8,0) animated:NO];
}completion: ^(BOOL finished){
}
];
timeSet-=0.1;
lblTime.text = [NSString stringWithFormat:@"%f",timeSet];
if(timeSet<=0)
{
[timer invalidate];
lblTime.text = @"0";
[UIView animateWithDuration: .1
animations: ^{
[scrollView setContentOffset:CGPointMake(0,0) animated:NO];
}completion: ^(BOOL finished){
}
];
}
}
答案 2 :(得分:0)
您可以使用Never Ended scrollView(其中包含For example this,例如关闭分页)。 现在通过这个你可以达到比例,通过使用页面编号或滚动视图的坐标,你可以找到上面显示的比例读数。
开始倒计时创建UIView contentOffset CGPointMake(10,100)的动画。
例如:
[UIView animateWithDuration: 1.5 /* Give Duration which was also on top */
animations: ^{
[scrollView setContentOffset:CGPointMake(0,0) animated:NO];
}completion: ^(BOOL finished){ }];