gpt4 book ai didi

ios - 像 facebook 聊天一样移动图像

转载 作者:行者123 更新时间:2023-11-28 22:10:39 24 4
gpt4 key购买 nike

我想制作类似 facebook 聊天 的动画:聊天头像。我创建了一个图标。它工作得很好而且很顺利。我创建了更多图标。他们也工作了。但是不一致facebook。是否有任何想法或引用来实现功能移动?

喜欢这个视频: Chat heads

最佳答案

尝试这个可能会有帮助..但它已经完成了 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);
}

我从这里得到这个..你可以在这里找到更多信息.. Draggable UIButton makes in iPhone & iPad

关于ios - 像 facebook 聊天一样移动图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23003746/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com