2011-09-08 31 views
15

Tôi có giao diện người dùng có chứa hai UIButton.Slide phụ trong hoạt ảnh, iphone

-(void)ViewDidLoad 
{ 
    geopointView = [[UIView alloc] initWithFrame:CGRectMake(0, 350, 120, 80)]; 
    geopointView.backgroundColor = [UIColor greenColor]; 

    UIButton *showGeoPointButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; 
    showGeoPointButton.frame = CGRectMake(0, 0, 120, 40); 
    showGeoPointButton.titleLabel.font = [UIFont systemFontOfSize:13.0]; 
    [showGeoPointButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
[showGeoPointButton addTarget:self action:@selector(showPlaces:) forControlEvents:UIControlEventTouchUpInside]; 

    UIButton *SaveButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain] 
    SaveButton.frame = CGRectMake(0, 40, 120, 40); 
    SaveButton.titleLabel.font = [UIFont systemFontOfSize: 15.0]; 
    [SaveButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
    [SaveButton addTarget:self action:@selector(savePlacePopUp) forControlEvents:UIControlEventTouchUpInside]; 

    [geopointView addSubview:showGeoPointButton]; 
    [geopointView addSubview:SaveButton]; 
} 

Tôi muốn tạo hiệu ứng động trong chế độ xem UI khi phương pháp sau được gọi.

-(void) showAnimation 

Tôi đã cố gắng thực hiện bằng cách làm theo nhưng tôi không thể thấy hoạt ảnh. Tôi làm nó như thế nào?

-(void) showAnimation{ 
    [UIView animateWithDuration:10.0 animations:^{ 
     [self.view addSubview:geopointView]; 
    }]; 
} 

Hướng dẫn để được trợ giúp trước.

Trả lời

60

Bạn cần thêm chế độ xem phụ có giá trị khung là nơi bạn muốn hoạt ảnh bắt đầu (tắt màn hình?) Sau đó thay đổi giá trị khung bên trong khối hoạt ảnh của bạn. Khung sẽ thay đổi theo thời gian, gây ra sự xuất hiện của chuyển động. Chế độ xem phải là một chế độ xem phụ - Tôi không tin rằng việc thêm một chế độ xem phụ là thứ bạn có thể tạo hiệu ứng động, điều đó không có ý nghĩa gì cả.

-(void)showAnimation { 

    [self.view addSubview:geopointView] 
    geopointView.frame = // somewhere offscreen, in the direction you want it to appear from 
    [UIView animateWithDuration:10.0 
        animations:^{ 
         geopointView.frame = // its final location 
        }]; 
} 
+0

Cảm ơn rất nhiều .. Nó hoạt động chính xác theo yêu cầu .. – alekhine

+0

đầu ra là gì ?? bạn có thể chỉ cho tôi một số ... tôi cần phải thực hiện điều đó – magid

Các vấn đề liên quan