<分区>
我正在开发一个社交应用程序,我想在其中实现类似于 instagram 的类似功能,当用户双击任何图像时,会出现带有类似于 instagram 的图像的提要,然后它应该显示一个心形图标和类似于 instagram 的动画。我试图做同样的事情但无法实现动画,谁能告诉我该怎么做。
我附上了类似 instagram 功能的图片。
<分区>
我正在开发一个社交应用程序,我想在其中实现类似于 instagram 的类似功能,当用户双击任何图像时,会出现带有类似于 instagram 的图像的提要,然后它应该显示一个心形图标和类似于 instagram 的动画。我试图做同样的事情但无法实现动画,谁能告诉我该怎么做。
我附上了类似 instagram 功能的图片。
最佳答案
这是一个实现:
- (void) animateLike {
[UIView animateWithDuration:0.3f delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
heartPopup.transform = CGAffineTransformMakeScale(1.3, 1.3);
heartPopup.alpha = 1.0;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.1f delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
heartPopup.transform = CGAffineTransformMakeScale(1.0, 1.0);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3f delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
heartPopup.transform = CGAffineTransformMakeScale(1.3, 1.3);
heartPopup.alpha = 0.0;
} completion:^(BOOL finished) {
heartPopup.transform = CGAffineTransformMakeScale(1.0, 1.0);
}];
}];
}];
}
Swift 3.0 代码
func likeAnimation() {
UIView.animate(withDuration: 0.3, delay: 0, options: .allowUserInteraction, animations: {() -> Void in
heartPopup.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
heartPopup.alpha = 1.0
}, completion: {(_ finished: Bool) -> Void in
UIView.animate(withDuration: 0.1, delay: 0, options: .allowUserInteraction, animations: {() -> Void in
heartPopup.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
}, completion: {(_ finished: Bool) -> Void in
UIView.animate(withDuration: 0.3, delay: 0, options: .allowUserInteraction, animations: {() -> Void in
heartPopup.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
heartPopup.alpha = 0.0
}, completion: {(_ finished: Bool) -> Void in
heartPopup.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
})
})
})
}
heartPopup
是一个 UIImageView,将其设置在图像中心的界面构建器中,并将其上的 alpha 设置为零。调用上面的方法来动画点赞效果。
if let bigLikeImageV = likeImageV, liked == true {
UIView.animate(withDuration: 0.6, delay: 0, usingSpringWithDamping: 0.4, initialSpringVelocity: 0.2, options: .allowUserInteraction, animations: {
bigLikeImageV.transform = CGAffineTransform(scaleX: 1.6, y: 1.6)
bigLikeImageV.alpha = 1.0
}) { finished in
bigLikeImageV.alpha = 0.0
bigLikeImageV.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
}
}
关于ios - 如何在ios中实现instagram similar like效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22140234/
相关文章:
instagram - 为什么我的 Instagram oauth 请求没有有效范围?
node.js - 上传到 Instagram 企业帐户的视频总是返回 "Media ID is not available"错误消息
swift - 如何创建像 Instagram 标签搜索一样的 CollectionView 标题?
iOS swift : Unexpectedly found nil while unwrapping optional value
ios - 创建 Safari Webarchives 的跨平台方式