- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在开发聊天应用程序。我正在使用 UIcollectionview
来显示消息。我正在尝试在发送按钮上创建动画。当用户点击发送 UIButton
时,我需要像 iMessage 这样的动画。为了创建这样的动画,我使用了两种不同的方式但没有得到正确的动画。我创建了一个演示。在那个演示中,我实现了不同的方法。
演示链接:
https://www.dropbox.com/s/z8rxjkpuxzs95kp/AdvanceCollection.zip?dl=0
下面是我真正需要的动画: https://www.dropbox.com/s/yo35lsm7yrc2oqu/Screen%20Recording.mov?dl=0
我采用了两种方法。以下是方法说明。
第一种方法:在第一种方法中,我自定义了 FlowLayout。我知道这是正确的方法,但没有得到正确的曲线动画。
override func initialLayoutAttributesForAppearingItem(at itemIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
guard let attributes = super.initialLayoutAttributesForAppearingItem(at: itemIndexPath),
let added = addedItem,
added == itemIndexPath else {
return nil
}
// set new attributes
attributes.frame = CGRect(x: 0, y: 0, width: 500, height: 500)
//attributes.center = CGPoint(x: self.collectionView!.frame.width - 23.5, y: -24.5)
attributes.center = CGPoint(x: 0.0, y: 100.0)
attributes.alpha = 1.0
attributes.transform = CGAffineTransform(scaleX: 0.15, y: 0.15)
attributes.zIndex = 20
return attributes
}
第二种方法: 在第二种方法中,我在 willdisplaycell
方法中实现动画。根据我的观点,我知道这不是自定义布局的正确方法,但我试过了。在第二种方法中,我从底部获取动画,但 x、y、width 和 height。此外,任何可见的动画也与 iMessage 发送消息动画
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
if !self.collectionData[indexPath.row].isAnimated
{
cell.frame = CGRect(x: 0, y: chatView.frame.origin.y, width: 1000.0, height: chatView.frame.size.height)
UIView.animate(withDuration: 10.0, delay: 0, usingSpringWithDamping: 0.4, initialSpringVelocity: 0.6, options: UIViewAnimationOptions.curveEaseIn, animations: {
cell.frame = CGRect(x:0, y: cell.frame.origin.y, width: cell.frame.size.width, height: cell.frame.size.height)
}, completion: { finished in
self.collectionData[indexPath.row].isAnimated = true
})
}
}
最佳答案
编辑:在此处查看 tableView 演示 animateCell
我假设您已经为您的 collectionView 创建了一个自定义的 xib 单元然后执行此操作
1- 将顶部、底部、前导、尾部约束正确设置为消息标签的 super View
2- 将消息标签的顶部约束更改为 400
3- 将顶部约束设置为 IBOutlet
4- 在 cellForRowAt 中将约束设置为 20
5- 然后做那样的动画
UIView.animateWithDuration(1.0,
{
cell.layoutSubview()
cell.layoutIfNeeded()
}
注意: collectionView 的问题是 item 的大小变化,所以动画可以发生,上面的解决方案与 tableView 完美配合
关于ios - 发送消息动画像iMessage发送消息使用UICollectionView自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47966698/
我看过This iMessage application is missing its required iMessage app extension ,但是答案并没有解决我的问题。 我的设备运行的是
我一直在通读 iMessage 文档,但对于 iMessage 应用程序是否可能收到消息提醒并从消息中获取特定内容,我还没有找到明确的答案。例如,收到某人发送了带有照片或链接的消息的提醒,然后能够抓取
使用 Xcode 8.0,在 iPhone(使用 iOS 10.0.2)上运行贴纸应用程序会出现此错误: 此 iMessage 应用程序缺少其所需的 iMessage 应用程序扩展 它在模拟器上运行良
有没有办法将行为类似于 Sticker App 贴纸的“真实”贴纸添加到您的自定义 iMessage 应用程序扩展?我能找到的唯一示例使用 MSMessageTemplateLayout,据我所知,它
是否可以(以编程方式)从 iMessage 应用程序扩展程序中检测:从发件人端:您正在与之交谈的人是否正在使用 iMessage,或者他们是 SMS/MMS 用户(例如 Android 或Window
有谁知道通过 twilio 机器人发送消息时是否可以使用这些消息效果(即五彩纸屑、用激光发送)?因此,要向聊天机器人添加“爵士乐”效果,我很想使用这些有趣的效果。 谢谢! 最佳答案 这里是 Twili
在我的项目中,我添加了 iMessage Extension,但我无法从 UITableview 发送所选数据(需要发送所选行数据) 声明 var savedConversation: MSConv
我注意到将工具栏放置在 iMessage 栏下方很困难,因为生成的 View Controller 似乎开始绘制在顶部 iMessage 栏所在的空间中。由于 iPhone 5s 的 iMessage
我有一个应用配置为向指定号码发送应用内短信。在 viewDidLoad 中,我检查设备是否可以使用 [MFMessageComposeViewController canSendText] 发送文本消
我正在尝试使用 InApp-Purchase 功能为 iMessage 创建扩展。基本上我创建了一个 iMessage 应用程序,它创建了两个目标。 您的 AppTarget 留言扩展 并且每个都有自
我正在尝试在 iOS 10 设备上开发 iMessage 应用程序。 想知道我是否可以检测接收器是否安装了我的应用程序? 因为我想在安装后执行某些操作,反之亦然。 最佳答案 看看这个链接: https
我有 iPhone 6。 苹果应用商店中是否有任何应用可以显示我的哪些联系人拥有 IOS iMessage?谷歌上有一些信息,但用于检查一一联系方式。我想一次性查看所有联系人 最佳答案 它已经旧了,但
我正在创建 iMessage 应用程序。我的问题是我不知道如何获取当前用户的名称。 我尝试过这样的: "\(conversation.selectedMessage?.senderParticipan
每当我在 iMessage 应用程序外部滑动以打开另一个 iMessage 应用程序,然后通过向后滑动返回到我的 iMessage 应用程序时,我的 iMessage 应用程序都会再次加载。 甚至 M
我进行了大量搜索并实现了从类似问题中找到的几个代码片段。 我已经使用了几个这样的已回答问题:iMessage Style Receding Keyboard in an iOS App 设置后退键盘。
我想制作一个像 imessage 这样的消息传递应用程序。当您键入一条消息时,其他用户会在消息气泡中看到动画中的三个点。如何用 React Native 做到这一点? 一个想法: View 应该是 L
他们是一种配置长按已发送消息的方法吗?例如,如果您长按文本,您可以复制和点击更多内容。目前我的应用程序只显示更多。他们是否也可以在自定义应用程序的操作表中添加副本? 最佳答案 不幸的是,我们无法获取对
我正在为现有项目开发 iMessage 应用程序扩展。当我在模拟器上运行它时,它工作得很好。但是当我尝试在设备上运行它时,状态显示“正在 iPhone 上运行 com.apple.MobileSMS”
我正在考虑在我的 iOS 应用程序中包含 iMessage 功能。我们可以通过在 iOS 中编程来定制它吗?我希望用户可以在群聊中阻止/禁用特定用户。可能吗? 最佳答案 不,这是不可能的,Apple
是否可以仅针对在 MFMessageComposeViewController 中具有聊天框的键盘访问该类? 我已经尝试过不同的 pod 来模拟相同的内容,但我认为最好的外观仍然是原生消息键盘聊天框。
我是一名优秀的程序员,十分优秀!