Skip to content
This repository has been archived by the owner on Apr 23, 2022. It is now read-only.

Latest commit

 

History

History
61 lines (44 loc) · 1.9 KB

README.md

File metadata and controls

61 lines (44 loc) · 1.9 KB

Watermark

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

DispatchQueue.global().async {
    guard let bilibili = UIImage(named: "bilibili"),
        let image = UIImage(named: "demo") else {
        return
    }
    let attr = NSAttributedString(string: "ID:2333333", attributes: [
        NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 16),
        NSAttributedStringKey.foregroundColor: UIColor.white])
    let processor =  WatermarkProcessor()
    var layout: WatermarkProcessor.Media.Position = (
        horizontal: (offset: 20, alignment: .end),
        vertical: (offset: 20, alignment: .start)
    )
    processor.addMedia(WatermarkProcessor.Media(image: bilibili, layout: layout))
    layout.vertical.offset += bilibili.size.height + 10
    processor.addMedia(WatermarkProcessor.Media(text: attr, layout: layout))
    guard let result = processor.process(origin: image) else {
        return
    }
    DispatchQueue.main.async {
        self.imageView.image = result
    }
}

Requirements

Installation

Watermark is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Watermark', :git => 'https://github.com/TBXark/Watermark.git'

Author

TBXark, [email protected]

License

Watermark is available under the MIT license. See the LICENSE file for more info.