我會實現,當你在我的應用程序請求的東西(如按下按鈕或任何),我想它會出現一個小的矩形,說「加載..」,當加載完成後,它會消失,並出現「向上滑動效應」。我做了一個簡單的模型來描述我想要達到的目標。你有什麼暗示給我嗎?謝謝。iPhone的加載視圖「幻燈片效果」
注:我不想拉刷新效果(加載視圖顯示沒有屏幕滾動,當你發送評論似乎爲例)
UPDATE:
我已經試過卷層雲代碼:
- (IBAction)displayLoadingScreen:(id)sender
{
NSLog(@"pressed");
UIView *loadingView = [[UIView alloc] init];
loadingView.frame = CGRectMake(0,-40,320,40);
[loadingView setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:loadingView];
//animate in within some method called when loading starts
[UIView animateWithDuration:1.0
animations:^{
loadingView.frame = CGRectMake(0,0,320,40);
}
completion:^(BOOL finished) {
}];
for (int i = 0; i < 10000; i++) {
NSLog(@"%d", i);
}
//animate out within some method called when loading ends
[UIView animateWithDuration:1.0
animations:^{
loadingView.frame = CGRectMake(0,-40,320,40);
}
completion:^(BOOL finished){
}];
}
爲什麼加載視圖在 for循環後滑動?如果你嘗試它,在打印for循環之前,執行完兩個動畫之後。想法?
更新2
- (void)stopLoading {
[UIView animateWithDuration:1.0
animations:^{
loadingView.frame = CGRectMake(0,-40,320,40);
}
completion:^(BOOL finished){
}];
}
- (void)startLoading {
loadingView.frame = CGRectMake(0,-40,320,40);
[loadingView setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:loadingView];
//animate in within some method called when loading starts
[UIView animateWithDuration:1.0
animations:^{
loadingView.frame = CGRectMake(0,0,320,40);
}
completion:^(BOOL finished) {
}];
sleep(5);
[self stopLoading];
}
- (IBAction)displayLoadingScreen:(id)sender
{
NSLog(@"button pressed");
[self startLoading];
}
嘗試閱讀'UIAnimation'類(並使用QuartzCore框架)。 – Raptor
或者,如果您想使用滑動下來更新Facebook等功能,請考慮使用'EGOTableViewPullRefresh'。 – Raptor