目录
目录README.md

Magic Images 📸

CI codecov Swift Version Tag Cocoapods Carthage compatible SPM compatible License

Overview

Magic Image is a library to facilitate the development of the image in various ways.

Support

iOS / tvOS

Usage

First Example

You can use it to view an image through a url, follow the example below

let photo: UIImageView = {
    let imageView = UIImageView()
    imageView.translatesAutoresizingMaskIntoConstraints = false
    return imageView
}()

override func viewDidLoad() {
    super.viewDidLoad()

    view.addSubview(photo)

    photo.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
    photo.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    photo.widthAnchor.constraint(equalToConstant: 100).isActive = true
    photo.heightAnchor.constraint(equalToConstant: 100).isActive = true

    MagicImages(image: photo).start(url: "IMAGE URL")
}

Second Example

You can use it to view a circular image. Measure is the width and height, follow the example below

let photo: UIImageView = {
    let imageView = UIImageView()
    imageView.translatesAutoresizingMaskIntoConstraints = false
    return imageView
}()

override func viewDidLoad() {
    super.viewDidLoad()

    view.addSubview(photo)

    photo.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
    photo.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true

    MagicImages(image: photo).start(url: "IMAGE URL").isCircle(measure: 100)
}

Third Example

You can use it to see an image with rounded edges. Measure is rounded edges, follow the example below

let photo: UIImageView = {
    let imageView = UIImageView()
    imageView.translatesAutoresizingMaskIntoConstraints = false
    return imageView
}()

override func viewDidLoad() {
    super.viewDidLoad()

    view.addSubview(photo)

    photo.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
    photo.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    photo.widthAnchor.constraint(equalToConstant: 300).isActive = true
    photo.heightAnchor.constraint(equalToConstant: 200).isActive = true
        
    MagicImages(image: photo).start(url: "IMAGE URL").isRounded(measure: 20)
}

Last Example

You can use it to see an image with some sides of the rounded edges. Measure is rounded edges, follow the example below

let photo: UIImageView = {
        let imageView = UIImageView()
        imageView.translatesAutoresizingMaskIntoConstraints = false
        return imageView
 }()

override func viewDidLoad() {
    super.viewDidLoad()

    view.addSubview(photo)

    photo.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
    photo.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    photo.widthAnchor.constraint(equalToConstant: 300).isActive = true
    photo.heightAnchor.constraint(equalToConstant: 200).isActive = true
        
    MagicImages(image: photo).start(url: "IMAGE URL").isSides([.topLeft, .bottomRight], measures: 50)
}

Examples with Interface Builder

1 - Circle

2 - Rounded Edges

Installation

Swift Package Manager
dependencies: [
    .package(url: "https://github.com/heroesofcode/MagicImages.git", .upToNextMajor(from: "0.4.3"))
]
import MagicImages
CocoaPods
import MagicImages
target '<Your Target Name>' do
    pod 'MagicImages'
end

OR

target '<Your Target Name>' do
    pod 'MagicImages', :git => "https://github.com/heroesofcode/MagicImages.git"
end
$ pod install
Carthage
github "heroesofcode/MagicImages"

Author

Coded by João Lucas

License

MIT License

Copyright (c) 2021 Heroes of Code

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号