PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 27, 2022

[FIXED] How to remove area of UIImage where user move his finger?

 July 27, 2022     crop, ios, swift, uiimage, xcode     No comments   

Issue

  • IMAGECROPPER
  • UIGESTURE
  • TOUCH

Needed to achieve this, User selects Image and then cut it with Touch drag like Photo Editing App.

enter image description here


Solution

         UIGraphicsBeginImageContext(drawImage.frame.size)
            var context = UIGraphicsGetCurrentContext()

            drawImage.image.draw(in: CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height - 50))

            context?.move(to: fromPoint)
            context?.addLine(to: toPoint)
            context?.setLineCap(.butt)
            context?.setLineWidth(2)
            context?.setBlendMode(.clear)
            context?.setShouldAntialias(true)

            UIColor.clear.set()

            context?.strokePath()

            let newImage = UIGraphicsGetImageFromCurrentImageContext()!


Answered By - Chanchal Warde
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing