使用Gallery视图对象。只需用想要水平滚动的图像填充它。这将是您希望实现的一个很好的近似值。
看我的视频http://www.youtube.com/watch?v=4acFshAlGJ8
我在scrollView中使用https://lh3.googleusercontent.com/-WZEDMSmfrK0/TeeD93t8qYI/AAAAAAAAAKw/X9D6jRkLfLk/s800/MUKScale.png图像作为Scale这是一个不完整的例子,只是为了说明它是如何实现的。
这里有一些有用的代码,在这里,一切都是静态的,但对于真正的工作,人们应该更多地工作,
- (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){
}
];
}
}
您可以使用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){ }];