2011-09-08 13 views
15

मेरे पास एक UIview है जिसमें दो UIButtons शामिल हैं।एनीमेशन में सबव्यू स्लाइड, आईफोन

-(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]; 
} 

मैं विधि को कॉल करते समय UIview में स्लाइड को एनिमेट करना चाहता हूं।

-(void) showAnimation 

मैंने इसे निम्नलिखित तरीके से करने की कोशिश की लेकिन मुझे कोई एनीमेशन नहीं दिखाई दे रहा है। मैं यह कैसे कर सकता हूं?

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

अग्रिम में किसी भी मदद के लिए Thannks।

उत्तर

60

आपको फ्रेम मान के साथ सबव्यूव जोड़ने की आवश्यकता है, जहां आप एनीमेशन (ऑफ-स्क्रीन?) से शुरू करना चाहते हैं, फिर अपने एनीमेशन ब्लॉक के अंदर फ्रेम मान बदलें। फ्रेम अवधि के दौरान बदल जाएगा, आंदोलन की उपस्थिति का कारण बनता है। दृश्य पहले से ही एक सबव्यूव होना चाहिए - मुझे विश्वास नहीं है कि सबव्यूव जोड़ना कुछ ऐसा है जिसे आप एनिमेट कर सकते हैं, इसका कोई मतलब नहीं है।

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

बहुत बहुत धन्यवाद .. यह बिल्कुल आवश्यक रूप से काम करता है .. – alekhine

+0

आउटपुट क्या है ?? क्या आप मुझे कुछ दिखा सकते हैं ... मुझे इसे लागू करने की ज़रूरत है – magid

संबंधित मुद्दे