2009-10-13 70 views

回答

1

使用圖庫視圖對象。只需填寫您想要水平滾動的圖像即可。 這將是一個很好的近似你想要達到的目標。

+0

歡迎SO。請求您提供支持您答案的代碼。 – Luv 2012-12-19 06:49:16

0

你可以使用從未結束的scrollView(For example this你有它像關閉分頁)。 現在,通過這個,您將實現規模,並通過使用頁面號或scrollview的座標,您可以找到上面顯示的比例尺讀數。

開始倒計時創建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){   }]; 
+0

你可以創建一個演示代碼嗎? – 2011-06-01 10:41:46

1

看到我的視頻 http://www.youtube.com/watch?v=4acFshAlGJ8

我使用 https://lh3.googleusercontent.com/-WZEDMSmfrK0/TeeD93t8qYI/AAAAAAAAAKw/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){ 

         } 
     ]; 
    } 

} 
+0

看起來像一個很好的解決方案,爲+1 +1 – 2012-12-06 16:56:38