Skip to content

JDrawView: A lightweight and flexible drawing view for iOS applications. Easy-to-use interface for implementing drawing functionality in Swift.

License

Notifications You must be signed in to change notification settings

wlxo0401/JDrawView

Repository files navigation

JDrawView

JDrawView is a lightweight and flexible drawing view for iOS applications. It provides an easy-to-use interface for implementing drawing functionality in your iOS apps.

Features

  • Simple and intuitive drawing interface
  • Customizable line color and width
  • Support for adding horizontal and vertical dash lines
  • Ability to clear the drawing
  • Convert drawing to UIImage
  • Copy drawing to clipboard

Example(It may take a long time to load because it's a GIF)

Function

ItemScrollView 데모

Copy

ItemScrollView 데모

Requirements

  • iOS 13.0+
  • Swift 5.0+

Installation

JDrawView is available through Swift Package Manager.

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/wlxo0401/JDrawView.git", .upToNextMajor(from: "1.0.4"))
]

Usage

  1. Import the module in your Swift file:
import JDrawView
  1. Create and add a JDrawView to your view hierarchy:
let drawView = JDrawView(frame: view.bounds)
view.addSubview(drawView)
  1. Customize the drawing:
// Set line color
drawView.setDrawColor(color: .red)

// Set line width
drawView.setDrawWidth(width: 5.0)

// Add dash lines
drawView.setHorizonDashLine(set: true)
drawView.setVerticalDashLine(set: true)
  1. Get the drawing as an image:
let image = drawView.asImage()
  1. Clear the drawing:
drawView.clearDrawing()

Example

import UIKit
import JDrawView

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let drawView = JDrawView()
        view.addSubview(drawView)

        drawView.translatesAutoresizingMaskIntoConstraints = false
        
        NSLayoutConstraint.activate([
            drawView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 20),
            drawView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 20),
            drawView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -20),
            drawView.heightAnchor.constraint(equalTo: drawView.widthAnchor),
        ])

        drawView.setDrawColor(color: .blue)
        drawView.setDrawWidth(width: 3.0)
    }
}

Contribution

Contributions are welcome! Please feel free to submit a Pull Request.

About

JDrawView: A lightweight and flexible drawing view for iOS applications. Easy-to-use interface for implementing drawing functionality in Swift.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages