黑马程序员技术交流社区
标题: IOS 抽屉效果 若有人能说出其中bug缘由 愿拜100金 [打印本页]
作者: Hello_world_ 时间: 2016-1-7 22:26
标题: IOS 抽屉效果 若有人能说出其中bug缘由 愿拜100金
@interface ViewController ()
@property (nonatomic,weak) UIView *rightView;
@property (nonatomic,weak) UIView *leftView;
@property (nonatomic,weak) UIView *mainView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIView *rightView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
rightView.backgroundColor = [UIColor greenColor];
_leftView = rightView;
UIView *leftView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
leftView.backgroundColor = [UIColor blueColor];
_leftView=leftView;
UIView *mainView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
mainView.backgroundColor = [UIColor redColor];
_mainView = mainView;
[self.view addSubview:rightView];
[self.view addSubview:leftView];
[self.view addSubview:mainView];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch =[touches anyObject];
CGPoint current = [touch locationInView:self.view];
CGPoint previous = [touch previousLocationInView:self.view];
CGFloat offX = current.x - previous.x;
if (_mainView.frame.origin.x>0) {
_leftView.hidden = NO;
CGRect frame = _mainView.frame;
frame.origin.x +=offX;
frame.origin.y +=offX*0.2;
frame.size.height -=offX*0.4;
_mainView.frame = frame;
}else if(_mainView.frame.origin.x<=0){
_leftView.hidden = YES;
CGRect frame = _mainView.frame;
frame.origin.x +=offX;
frame.origin.y +=(-offX)*0.2;
frame.size.height -=(-offX)*0.4;
_mainView.frame = frame;
}
}
@end
该程序运行是会有Bug的,,求高人指点一二,算法上没有问题,个人感觉比
作者: JC小子 时间: 2016-1-7 23:56
还在学习中,楼主也要好好努力学习
作者: 雪中飞 时间: 2016-1-12 23:14
努力学习中
作者: rolandzhao 时间: 2016-1-15 20:58
。。。争取尽快能看懂
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) |
黑马程序员IT技术论坛 X3.2 |