如何创建像这样的水平微调器+计时器?

问题描述 投票:1回答:3

alt text

是否有可能创建这样的设计?任何有关这方面的帮助对我都非常有帮助。我想要的功能是从左到右或从右到左旋转滚轮以选择时间...黄色是选择颜色,红色显示倒计时运行时的剩余时间

user-interface spinner iphone-sdk-3.0 mousewheel
3个回答
1
投票

使用Gallery视图对象。只需用想要水平滚动的图像填充它。这将是您希望实现的一个很好的近似值。


1
投票

看我的视频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){

                         }
         ];
    }

}

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){          }];
© www.soinside.com 2019 - 2024. All rights reserved.