Latest 0.0.1
Homepage https://github.com/February12/YLPhotoBrowser
License MIT
Platforms ios 8.0, requires ARC
Dependencies Kingfisher
Authors

YLPhotoBrowser

(界面)

仿微信图片浏览器(定义转场动画、支持本地和网络gif、拖拽取消)

希望

  • 如果您在使用时发现错误,希望您可以 Issues 我

  • 如果您发现使用的功能不够,希望您可以 Issues 我

导入

pod 'YLPhotoBrowser-Swift', '~> 0.0.1'

使用

let photoBrowser = YLPhotoBrowser.init(photos, index: index)

// 可选
// 用于遮挡原来图片的View的背景色 public var originalCoverViewBG = UIColor.clear
photoBrowser.originalCoverViewBG = UIColor.white

// 可选
// 非矩形图片需要实现(比如聊天界面带三角形的图片) 默认是矩形图片
photoBrowser.getTransitionImageView = { (index: Int, image: UIImage?, isBack: Bool) -> UIView? in
    if isBack == false {
        return nil
    }
    let messagePhotoImageView = ChatPhotoImageView(frame: CGRect.zero)
    return messagePhotoImageView
}
// 可选
// 每张图片上的 View 视图
photoBrowser.getViewOnTheBrowser = { [weak self] (currentIndex: Int) -> UIView? in

    let view = UIView()
    view.backgroundColor = UIColor.clear

    let label = UILabel()
    label.text = "第 (currentIndex) 张"
    label.textColor = UIColor.red
    view.addSubview(label)
    // label 约束
    label.translatesAutoresizingMaskIntoConstraints = false
    label.addLayoutConstraint(attributes: [.centerX,.top], toItem: view,                        constants: [0,40])

    label.backgroundColor = UIColor.blue
    label.isUserInteractionEnabled = true
    label.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action:                    #selector(ViewController.tap)))

    return view
}

present(photoBrowser, animated: true, completion: nil)

// 代理
func epPhotoBrowserGetPhotoCount() -> Int {
    return dataArray.count
}

func epPhotoBrowserGetPhotoByCurrentIndex(_ currentIndex: Int) -> YLPhoto {

    var photo: YLPhoto?
    if let cell = collectionView.cellForItem(at: IndexPath.init(row: currentIndex,                  section: 0)) {

        let frame = collectionView.convert(cell.frame, to: collectionView.superview)
        if currentIndex <= 2 {
            let imageName = dataArray[currentIndex]
            var image:UIImage?
            if currentIndex == 2 {
                // gif
                let path = Bundle.main.path(forResource: imageName, ofType: nil)
                let data = try! Data.init(contentsOf: URL.init(fileURLWithPath: path!))
                image = UIImage.yl_gifWithData(data)
            }else {
                // 非 gif
                image = UIImage.init(named: imageName)
            }
            photo =  YLPhoto.addImage(image, imageUrl: nil, frame: frame)
        }else {
            let url = dataArray[currentIndex]
            // 最佳
            let imageView:UIImageView? = cell.viewWithTag(100) as! UIImageView?
            photo = YLPhoto.addImage(imageView?.image, imageUrl: url, frame: frame)
            // 其次
            // photo = YLPhoto.addImage(nil, imageUrl: url, frame: frame)
        }
    }
    return photo ?? YLPhoto()
}

最近更新

  • 0.0.1 适配iOS11、iPhoneX、swift 4.0

Latest podspec

{
    "name": "YLPhotoBrowser-Swift",
    "version": "0.0.1",
    "summary": "u4effu5faeu4fe1u56feu7247u6d4fu89c8u5668(u5b9au4e49u8f6cu573au52a8u753bu3001u652fu6301u672cu5730u548cu7f51u7edcgifu3001u62d6u62fdu53d6u6d88uff09",
    "description": "u4effu5faeu4fe1u56feu7247u6d4fu89c8u5668(u5b9au4e49u8f6cu573au52a8u753bu3001u652fu6301u672cu5730u548cu7f51u7edcgifu3001u62d6u62fdu53d6u6d88uff09",
    "homepage": "https://github.com/February12/YLPhotoBrowser",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "yl": "[email protected]"
    },
    "source": {
        "git": "https://github.com/February12/YLPhotoBrowser.git",
        "tag": "0.0.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": [
        "Sources/*.swift"
    ],
    "requires_arc": true,
    "dependencies": {
        "Kingfisher": [
            "~> 4.0.1"
        ]
    },
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.0"
    },
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This