亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        用Animation實(shí)現(xiàn)iphone動(dòng)畫(huà)效果

        字號(hào):


            1、寫(xiě)了一個(gè)小Demo,實(shí)現(xiàn)上下移動(dòng)的效果圖:
            名單1
            名單2
            名單3
            主要代碼如下:
            - (IBAction)upChange:(id)sender {
            if (typeView == down) {
            [self.downBtn setHidden:NO];
            [self.upBtn setHidden:NO];
            [UIView animateWithDuration:0.5 animations:^{
            self.upView.center = CGPointMake(self.upView.center.x, 0);
            self.downView.center = CGPointMake(self.downView.center.x, (self.upView.frame.size.height+self.downView.frame.size.height)/2);
            }];
            typeView = middle;
            }else if(typeView == middle){
            [self.downBtn setHidden:NO];
            [self.upBtn setHidden:YES];
            [UIView animateWithDuration:0.5 animations:^{
            self.upView.center = CGPointMake(self.upView.center.x, -(self.upView.frame.size.height/2));
            self.downView.center = CGPointMake(self.downView.center.x, self.downView.frame.size.height/2);
            }];
            typeView = up;
            }
            }
            - (IBAction)downChange:(id)sender {
            if (typeView == middle) {
            [self.downBtn setHidden:YES];
            [self.upBtn setHidden:NO];
            [UIView animateWithDuration:0.5 animations:^{
            self.upView.center = CGPointMake(self.upView.center.x, self.upView.frame.size.height/2);
            self.downView.center = CGPointMake(self.downView.center.x, self.upView.frame.size.height+self.downView.frame.size.height/2);
            }];
            typeView = down;
            }else if(typeView == up)
            {
            [self.downBtn setHidden:NO];
            [self.upBtn setHidden:NO];
            [UIView animateWithDuration:0.5 animations:^{
            self.upView.center = CGPointMake(self.upView.center.x, 0);
            self.downView.center = CGPointMake(self.downView.center.x, (self.upView.frame.size.height+self.downView.frame.size.height)/2);
            }];
            typeView = middle;
            }
            }
            這是主要的代碼,另外還有一些需要注意的一些小細(xì),如你的兩個(gè)view的大小,需要計(jì)算出精確位置。
            下面開(kāi)始學(xué)習(xí)[UIView animateWithDuration]方法的使用:
            函數(shù)原型:
            + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0); // delay = 0.0, options = 0, completion = NULL
            duration:動(dòng)畫(huà)持續(xù)時(shí)間
            animations:該代碼兒塊中是所有view要完成的動(dòng)畫(huà)的所有屬性的定義;
            還有另外兩個(gè)函數(shù):
            + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);
            + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);// delay = 0.0, options = 0
            options:是動(dòng)畫(huà)執(zhí)行的選項(xiàng)
            completion:是動(dòng)畫(huà)完成以后所要執(zhí)行的代碼塊兒。