[Swift]时间处理、时间选择器和图片选择器

SwiftDate

GitHub:https://github.com/malcommac/SwiftDate
SwiftDate 中文文档:https://www.jianshu.com/p/1b6e8a764800

CocoaPods

pod 'SwiftDate'

 

YLDatePicker

GitHub:https://github.com/February12/YLDatePicker

import UIKit

class YLDatePickerShowViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    /*
    // 显示时间类型
    public enum YLDatePickerType:String {
        case YM      // 年月
        case MD      // 月日
        case YMD     // 年月日
        case YMDHm   // 年月日时分
        case MDHm    // 月日时分
        case Hm      // 时分
    }

    // 默认最小时间
    fileprivate var minLimitDate = Date.init(timeIntervalSince1970: TimeInterval(0))
    // 默认最大时间
    fileprivate var maxLimitDate = Date.init(timeIntervalSince1970: TimeInterval(9999999999))
    // 首次显示时间(currentDate) 不设置默认当前时间
    */
    @IBAction func tapSelectTimeAction(_ sender: Any) {
        let but = sender as! UIButton;
        let datePicker = YLDatePicker(currentDate: nil, minLimitDate: Date(), maxLimitDate: nil, datePickerType: .YMDHm) { [weak self] (date) in
            but.setTitle(date.getString(format: "yyyy-MM-dd HH:mm"), for: .normal);
        }
        datePicker.show()
    }
    
}

 

HEPhotoPicker

GitHub:https://github.com/heyode/HEPhotoPicker
CocoaPods

pod 'HEPhotoPicker'

import UIKit
import HEPhotoPicker

class HEPhotoPickerShowViewController: UIViewController, HEPhotoPickerViewControllerDelegate {

    var selectObjects : [HEPhotoAsset]?
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func tapSelectPictureOrVideo(_ sender: Any) {
        // 配置项
        let option = HEPickerOptions.init()
        // 只能选择一个图片
        // option.singleImage = true
        // 只能选择一个视频
        // option.singleVideo = true
        // 图片和视频只能选择一种
        option.mediaType = .imageAndVideo
        // 将上次选择的数据传入,表示支持多次累加选择,
        option.defaultSelections = self.selectObjects
        // 选择图片的最大个数
        option.maxCountOfImage = 9
        // 创建选择器
        let picker = HEPhotoPickerViewController.init(delegate: self, options: option)
        // 弹出
        hePresentPhotoPickerController(picker: picker, animated: true)
    }
    
    func pickerController(_ picker: UIViewController, didFinishPicking selectedImages: [UIImage], selectedModel: [HEPhotoAsset]) {

    }

}



 

 

 

 

 

你可能感兴趣的:([Swift]学习笔记)