Support custom ZLEditImageViewController
hoangnam714 opened this issue · 21 comments
In the next version, I will change the authority of ZLEditImageViewController to open. You can subclass this class to customize something.
I hope you can release a new version soon, for now can I use your code for commercial application, I need to edit the included toolkit
@longitachi Do you can exchange quickly through applications such as slack, message, whatapp,...
slack: zl495181165@gmail.com
Can you accept my invitation to join my workspace, I have some questions
Can you accept my invitation to join my workspace, I have some questions
No, here is my whatsapp id: longitachi
The license is MIT, so you can use this software in commercial applications.
Thank you for your help, I hope to be able to contribute something in the future
ZLImageEditor
oh no, can you support ZLEditImageViewController to UIVIew so I can embed into another viewcotroller, this makes it easier to customize ui of ZLEditImageViewController, currently I can only present ZLEditImageViewController @longitachi
You could instatiate the VC and use it's view property to embed in another VC as child or so...
@shadzik
Looks like @longitachi forgot to publicize the ZLEditImageViewController constructor, so I can't do it the way you suggested.
Yes, you're right, for the time being you could just make the init method public. Or create a PR that publishes a convenient init method.
@shadzik Looks like @longitachi forgot to publicize the ZLEditImageViewController constructor, so I can't do it the way you suggested.
1.1.1 fixed
You can do it like this
class ImageStickerContainerView: UIView, ZLImageStickerContainerDelegate {
func show(in view: UIView) {
let vc = ImageStickerViewController()
vc.hideBlock = { [weak self] in
self?.hide()
}
getTopViewController()?.showDetailViewController(vc, sender: nil)
}
}
class ImageStickerViewController: UIViewController {
var hideBlock: (() -> Void)?
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
// Do any additional setup after loading the view.
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
hideBlock?()
}
}
Ohno... @longitachi
I see some of the following problems:
I think it would be better if you fork this repo and then add the custom features you need...
@longitachi Thank you for your help,
I tried with some code and found the following code works quite well, but I am confused when applying this code to ZLImageStickerView pangeture and ZLTextStickerView, can you help me. Below is the support code
@objc func handlePan(_ gesture: UIPanGestureRecognizer) {
let translation = gesture.translation(in: _Container_image_view)
guard let gestureView = gesture.view else {
return
}
gestureView.center = CGPoint(
x: gestureView.center.x + translation.x,
y: gestureView.center.y + translation.y
)
gesture.setTranslation(.zero, in: _Container_image_view)
guard gesture.state == .ended else {
return
}
let velocity = gesture.velocity(in: _Container_image_view)
let magnitude = sqrt((velocity.x * velocity.x) + (velocity.y * velocity.y))
let slideMultiplier = magnitude / 200
let slideFactor = 0.1 * slideMultiplier
var finalPoint = CGPoint(
x: gestureView.center.x + (velocity.x * slideFactor),
y: gestureView.center.y + (velocity.y * slideFactor)
)
finalPoint.x = min(max(finalPoint.x, 0), _Container_image_view.bounds.width)
finalPoint.y = min(max(finalPoint.y, 0), _Container_image_view.bounds.height)
UIView.animate(
withDuration: Double(slideFactor * 2),
delay: 0,
options: .curveEaseOut,
animations: {
gestureView.center = finalPoint
})
}
Sorry, I don't understand your question. What does this code do?
this code works as keep the imagesticker always inside the viewcontainer
Simulator.Screen.Recording.-.iPhone.8.Plus.-.2022-05-18.at.13.43.01.mp4
I sent a message to whatsapp, did you receive it, I think it will be easier to communicate there