是否可以创建这样的设计?任何有关这方面的帮助对我来说都非常有帮助。我想要的功能是从左到右或从右到左旋转轮子以选择时间......黄色是选择颜色,红色是显示倒计时运行时的剩余时间
问问题
1419 次
3 回答
1
使用画廊视图对象。只需用要水平滚动的图像填充它。这将是您想要实现的目标的一个很好的近似值。
于 2010-06-24T15:08:05.047 回答
1
看我的视频 http://www.youtube.com/watch?v=4acFshAlGJ8
我已经使用 https://lh3.googleusercontent.com/-WZEDMSmfrK0/TeeD93t8qYI/AAAAAAAAAAKw/X9D6jRkLfLk/s800/MUKScale.png 图像作为滚动视图中的比例,这是一个不完整的示例,只是为了说明它是如何实现的。
这是一些有用的代码,在此大约所有内容都是静态的,但对于真正的工作,应该做更多的工作,
- (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){
}
];
}
}
于 2011-06-02T13:04:30.873 回答
0
您可以使用永无止境的滚动视图(例如,您在其中有这个,就像关闭分页一样)。现在通过这个您将获得比例,并通过使用页面编号或滚动视图的坐标,您可以找到上面显示的比例读数。
在开始倒计时创建 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){ }];
于 2011-06-01T08:13:03.883 回答