侧滑

侧滑,第1张

概述侧滑

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

////  VIEwController.m//  CeHua////  Created by mac on 15-4-14.//  copyright (c) 2015年 mac. All rights reserved.//#import "VIEwController.h"#import "leftVIEwController.h"#import "RightVIEwController.h"//取屏幕寬高#@R_301_5552@ KscreenWIDth [UIScreen mainScreen].bounds.size.wIDth#@R_301_5552@ KscreenHeigh [UIScreen mainScreen].bounds.size.height@interface VIEwController (){    CGPoint _point0;//初始point        leftVIEwController *_left;    RightVIEwController *_right;}@end@implementation VIEwController- (voID)vIEwDIDLoad {    [super vIEwDIDLoad];    // Do any additional setup after loading the vIEw,typically from a nib.        self.vIEw.backgroundcolor = [UIcolor orangecolor];        //初始化左右視圖    _left = [[leftVIEwController alloc] init];    _left.vIEw.frame = CGRectMake(-200,KscreenWIDth,KscreenHeigh);    _left.vIEw.Alpha = 0;        _right = [[RightVIEwController alloc] init];    _right.vIEw.frame = CGRectMake((KscreenWIDth - (KscreenWIDth/4)),KscreenHeigh);    _right.vIEw.Alpha = 0;        /*          第二种方式          在这里不设置frame值  把左右视图当做子视图加到主视图上 当触摸结束时改变左右视图的frame值          第三种方式          把左右控制器当子控制器加到主控制器上 触摸结束时改变frame值并把视图插入主界面     */    }//觸摸開始時的事件- (voID)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{    //取觸摸點座標    UItouch *touch = [touches anyObject];    _point0 = [touch locationInVIEw:self.vIEw];    UIImageVIEw *iamgeVIEw = [[UIImageVIEw alloc] initWithFrame:CGRectMake(_point0.x,_point0.y,20,20)];    iamgeVIEw.image = [UIImage imagenamed:@"0.jpg"];    [self.vIEw addSubvIEw:iamgeVIEw];        [UIVIEw animateWithDuration:.75                     animations:^{                         iamgeVIEw.Alpha = 0;                     } completion:^(BOol finished) {                         [iamgeVIEw removeFromSupervIEw];                     }];    }//手指移動時的時間- (voID)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{    UItouch *touch = [touches anyObject];    CGPoint point = [touch locationInVIEw:self.vIEw];    UIImageVIEw *iamgeVIEw = [[UIImageVIEw alloc] initWithFrame:CGRectMake(point.x,point.y,20)];    iamgeVIEw.image = [UIImage imagenamed:@"0.jpg"];    [self.vIEw addSubvIEw:iamgeVIEw];        [UIVIEw animateWithDuration:.5                     animations:^{                         iamgeVIEw.Alpha = 0;                     } completion:^(BOol finished) {                         [iamgeVIEw removeFromSupervIEw];                     }];    }//觸摸結束時的事件- (voID)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{    //判斷左右視圖出現的時機    UItouch *touch = [touches anyObject];    CGPoint point = [touch locationInVIEw:self.vIEw];        if (_left.vIEw == nil) {                _left = [[leftVIEwController alloc] init];        _left.vIEw.frame = CGRectMake(-200,KscreenHeigh);        _left.vIEw.Alpha = 0;            }    if (_right.vIEw == nil) {                        _right = [[RightVIEwController alloc] init];        _right.vIEw.frame = CGRectMake((KscreenWIDth - (KscreenWIDth / 4)),KscreenHeigh);        _right.vIEw.Alpha = 0;    }        if (200 < (point.x - _point0.x)) {                        [UIVIEw animateWithDuration:.75                         animations:^{                                                          if (_right.vIEw.Alpha == 0) {                                                                  _left.vIEw.Alpha = 1;                                 [self.vIEw addSubvIEw:_left.vIEw];                             }                                                          _right.vIEw.Alpha = 0;                             [_right.vIEw removeFromSupervIEw];                                                      } completion:^(BOol finished) {                                                      }];            }else if (200 < (_point0.x - point.x)){                [UIVIEw animateWithDuration:.75                         animations:^{                                                          if (_left.vIEw.Alpha == 0) {                                                                  _right.vIEw.Alpha = 1;                                 [self.vIEw addSubvIEw:_right.vIEw];                                                              }                                                          _left.vIEw.Alpha = 0;                             [_left.vIEw removeFromSupervIEw];                                                                                   } completion:^(BOol finished) {                                                      }];        }}- (voID)dIDReceiveMemoryWarning {    [super dIDReceiveMemoryWarning];    // dispose of any resources that can be recreated.}@end

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的侧滑全部内容,希望文章能够帮你解决侧滑所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1107855.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存