开发者

how to create horizontal spinner+timer like this?

开发者 https://www.devze.com 2022-12-08 03:58 出处:网络
is it possible to create a design something like this? any help regarding this would be very helpful for me.the functionality i want is to rotate the wheel left-to-right or right to left for select

how to create horizontal spinner+timer like this?

is it possible to create a design something like this? any help regarding this would be very helpful for me.the functionality i want is to rotate the wheel left-to-right or right to left for selecting time...yellow is selection color and red is shows开发者_JS百科 the remaining time when countdown is running


Use a Gallery view object. Just fill it with the images you want to scroll horizontally. This would be a good approximation to what you're looking to achieve.


See my video http://www.youtube.com/watch?v=4acFshAlGJ8

I have use https://lh3.googleusercontent.com/-WZEDMSmfrK0/TeeD93t8qYI/AAAAAAAAAKw/X9D6jRkLfLk/s800/MUKScale.png image as Scale in the scrollView this is an incomplete example just to show how can it is achievable.

here is some helpful piece of code, in this approx everything is static but for the real work one should to work more,

   - (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){

                         }
         ];
    }

}


You can use a Never Ended scrollView (For example this you have in it like off paging). Now by this you will achieve the scale and by using page no or coordinates of the scrollview you can find the scale reading to show on above.

On start count down create animation of UIView contentOffset CGPointMake(10, 100).

for example:

[UIView animateWithDuration: 1.5 /* Give Duration which was also on top */
                 animations: ^{
                     [scrollView setContentOffset:CGPointMake(0,0) animated:NO];
                 }completion: ^(BOOL finished){          }];
0

精彩评论

暂无评论...
验证码 换一张
取 消