【问题标题】:how to create horizontal spinner+timer like this?如何创建这样的水平微调器+计时器?
【发布时间】:2019-04-30 21:05:17
【问题描述】:

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

【问题讨论】:

    标签: user-interface spinner iphone-sdk-3.0 mousewheel


    【解决方案1】:

    使用图库视图对象。只需用要水平滚动的图像填充它。 这将是您想要达到的目标的一个很好的近似值。

    【讨论】:

    • 欢迎来到 SO。请您提供一个代码来支持您的回答。
    【解决方案2】:

    看我的视频 http://www.youtube.com/watch?v=4acFshAlGJ8

    我用过 https://lh3.googleusercontent.com/-WZEDMSmfrK0/TeeD93t8qYI/AAAAAAAAAKw/X9D6jRkLfLk/s800/MUKScale.png 在 scrollView 中将图像作为 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){
    
                             }
             ];
        }
    
    }
    

    【讨论】:

      【解决方案3】:

      您可以使用永无止境的滚动视图(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){          }];
      

      【讨论】:

        猜你喜欢
        • 2017-04-10
        • 1970-01-01
        • 2015-04-07
        • 2016-10-21
        • 2013-12-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-07
        相关资源
        最近更新 更多