Animation 如何将.gif格式的标签添加到Swift 3中的I message应用程序?
我被一个问题绊倒了你能解决我吗 事实上,我正在为imessage应用程序实现自定义贴纸包。为此,我实现了所有的事情,工作正常,但只有一个案例 因此,如果我添加.jpg或.png格式的文件,它的显示和发送会非常完美。如果我为贴纸添加.gif格式的图像,则在显示时间时不会设置动画 显示我使用的集合视图的目的Animation 如何将.gif格式的标签添加到Swift 3中的I message应用程序?,animation,browser,swift3,gif,mssticker,Animation,Browser,Swift3,Gif,Mssticker,我被一个问题绊倒了你能解决我吗 事实上,我正在为imessage应用程序实现自定义贴纸包。为此,我实现了所有的事情,工作正常,但只有一个案例 因此,如果我添加.jpg或.png格式的文件,它的显示和发送会非常完美。如果我为贴纸添加.gif格式的图像,则在显示时间时不会设置动画 显示我使用的集合视图的目的MSStickerView 我的代码是: func LoadStickers() { for i in 1...5 { if let url = Bundle.main
MSStickerView
我的代码是:
func LoadStickers()
{
for i in 1...5 {
if let url = Bundle.main.url(forResource: "nature\(i)", withExtension: "gif") {
do {
let sticker = try MSSticker(contentsOfFileURL: url, localizedDescription: "")
stickers.append(sticker)
} catch {
print(error)
}
}
以下是我的收藏视图委托:
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return stickers.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "StickerPackCell", for: indexPath) as! FemaleStickerPackViewCell
// Configure the cell
cell.femaleStickerPack.sticker = stickers[indexPath.row]
return cell
}
这是UICollectionViewCell
:
class StickerViewCell: UICollectionViewCell {
@IBOutlet var femaleStickerPack: MSStickerView!
}
这是分机:
extension UIViewController
{
func addTo(appViewController host:MSMessagesAppViewController)
{
willMove(toParentViewController: host)
host.addChildViewController(self)
view.frame = host.view.bounds
view.translatesAutoresizingMaskIntoConstraints = false
host.view.addSubview(view)
view.topAnchor.constraint(equalTo: host.view.topAnchor).isActive = true
view.bottomAnchor.constraint(equalTo: host.view.bottomAnchor).isActive = true
view.leftAnchor.constraint(equalTo: host.view.leftAnchor).isActive = true
view.rightAnchor.constraint(equalTo: host.view.rightAnchor).isActive = true
didMove(toParentViewController: host)
}
}
所以我想储存.gif格式的贴纸。有人能帮我吗?我尝试了很多方法,但都失败了
提前谢谢。有人能帮我吗有人能帮我吗?我在等你的答复。你能马上寄过来吗?