如何快速增加MSStickerBrowserView?

时间:2019-02-21 17:09:56

标签: ios swift imessage ios-stickers

enter image description here

我将 MSStickerBrowserView 用于iMessage应用程序。但是,当我扩展此视图时,此高度视图不会因其超级视图而增加。我希望此视图的大小由其超级视图增加。

这是我当前的增加其高度的代码,但无法正常工作

class StickerBrowserView: MSStickerBrowserView, MSStickerBrowserViewDataSource {

    var pack: String!
    var numStickers: Int!
    var stickerViewTopConstraint: NSLayoutConstraint!

    func load() {
        //stickerViewTopConstraint.constant = -15
        self.dataSource = self
       // self.contentOffset = CGPoint(x: self.frame.origin.x, y: 20)
        self.contentInset = UIEdgeInsets(top: 30, left: 0, bottom: 0, right: 0)
        self.reloadData()
        self.frame = CGRect(x: 0, y: 0, width:UIScreen.main.bounds.size.width , height: UIScreen.main.bounds.size.height)
        print("frame \(frame)")
        self.backgroundColor = UIColor.lightGray.withAlphaComponent(0.5)
        self.layoutIfNeeded()
       // self.frame = UIScreen.main.bounds


    }    


    func numberOfStickers(in stickerBrowserView: MSStickerBrowserView) -> Int {
        return numStickers
    }

    func stickerBrowserView(_ stickerBrowserView: MSStickerBrowserView, stickerAt index: Int) -> MSSticker {
        let path = "APNG/\(pack!)/\(pack!)_sticker\(index+1).png"

        let docDir = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
        let imageURL = docDir.appendingPathComponent(path)

        var sticker: MSSticker?
        do {
            sticker = try MSSticker(contentsOfFileURL: imageURL, localizedDescription: "")
        } catch {
            print(error)
        }

        return sticker!
    }

}

0 个答案:

没有答案