Baby小破孩

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
[view_button addTarget:self action:@selector(dragBegan:withEvent: )
             forControlEvents: UIControlEventTouchDown];
[view_button addTarget:self action:@selector(dragMoving:withEvent: )
                forControlEvents: UIControlEventTouchDragInside];
[view_button addTarget:self action:@selector(dragEnded:withEvent: )
                forControlEvents: UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
 
 
 
- (void) dragBegan: (UIControl *) c withEvent:ev
 
 
{
NSLog(@"Button  moving bagin ......");
 
}
 
 
- (void) dragMoving: (UIControl *) c withEvent:ev
{
NSLog(@"Button  is moving ..............");
    UIButton *bt = (UIButton *)c;
    c.center = [[[ev allTouches] anyObject] locationInView:self.view];
}
- (void) dragEnded: (UIControl *) c withEvent:ev
{
NSLog(@"Button  moving end..............");
    UIButton *bt = (UIButton *)c;
    c.center = [[[ev allTouches] anyObject] locationInView:self.view];
}

 

posted on 2013-05-30 11:46  Baby小破孩  阅读(195)  评论(0编辑  收藏  举报