2014-04-11 140 views
0

我想製作像facebook chat這樣的動畫:聊天頭像。我創建了一個圖標。它運行良好,非常順利。我創建了更多圖標。他們也工作。但不一致facebook。是否有任何想法或參考實現功能移動?像facebook聊天一樣移動圖像

喜歡這部影片: Chat heads

+0

什麼是特徵移動? – square

+0

試試這個從github的樣本.. https://github.com/Tech-Dev-Mobile/IOS-Message-Chat – svmrajesh

+0

@square:我的意思是聊天頭。我編輯 – TienLe

回答

2

嘗試,這可能是幫助全..但它已經做了的UIButton ..

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[button setTitle:@"Drag me!" forState:UIControlStateNormal]; 

// add drag listener 
[button addTarget:self action:@selector(wasDragged:withEvent:) 
forControlEvents:UIControlEventTouchDragInside]; 

// center and size 
button.frame = CGRectMake((self.view.bounds.size.width - 100)/2.0, 
          (self.view.bounds.size.height - 50)/2.0, 
          100, 50); 

// add it, centered 

[self.view addSubview:button]; 


- (void)wasDragged:(UIButton *)button withEvent:(UIEvent *)event 
{ 
    // get the touch 
UITouch *touch = [[event touchesForView:button] anyObject]; 

// get delta 
CGPoint previousLocation = [touch previousLocationInView:button]; 
CGPoint location = [touch locationInView:button]; 
CGFloat delta_x = location.x - previousLocation.x; 
CGFloat delta_y = location.y - previousLocation.y; 

// move button 
button.center = CGPointMake(button.center.x + delta_x, 
          button.center.y + delta_y); 
} 

我得到這個從這裏..for更多信息,你可以找到這裏.. Draggable UIButton makes in iPhone & iPad

+0

其工作正常..應該接受這... –