MoView by hyouuu, made for Pendo, based on SPUserResizableView.
It is a movable & resizable view for both iOS & macOS, with works perfectly with images, and provides Save, Copy and Delete menu options.
It has been used by Pendo in App Store with lots of users, so is considered production ready. Pull requests are always welcome!
Seems like CocoaPod doesn't work well with multi platform support (or maybe the podspec setup is wrong?), thus currently please directly copy paste MoView and MacMoView into your project. If you are a CocoaPod expert and could find out what's wrong it'd be super helpful!
In your view controller:
import MoView
class YourViewController: UIViewController, MoViewDelegate {
// Get a hold of MoViews
var mediaViews = [MoView]()
// Example setup
let imageFrame = CGRect(x: posX, y: posY, width: width, height: height)
let mediaView = MoView(frame: imageFrame)
mediaView.copyItemTitle = local("copy")
mediaView.saveItemTitle = local("save")
mediaView.deleteItemTitle = local("delete")
let imageView = UIImageView(image:image)
imageView.alpha = 0.9
mediaView.contentView = imageView
mediaView.delegate = self
textView.addSubview(mediaView)
mediaViews.append(mediaView)
// Implement MoViewDelegate - provided some example usages below
// MARK: MoViewDelegate
func moViewTapped(moView: MoView) {
log("moViewTapped")
}
func moViewDidBeginEditing(moView: MoView) {
log("moViewDidBeginEditing")
textView.bringSubview(toFront: moView)
}
func moViewDidEndEditing(moView: MoView, edited: Bool) {
log("moViewDidEndEditing")
}
func moViewCopyTapped(moView: MoView) {
if let imageView = moView.contentView as? UIImageView {
if let image = imageView.image {
let pasteboard = UIPasteboard.generalPasteboard()
if let data = UIImagePNGRepresentation(image) {
pasteboard.setData(data, forPasteboardType: "public.png")
return
}
}
}
assertionFailure("copyItem failed")
}
func moViewSaveTapped(moView: MoView) {
if let imageView = moView.contentView as? UIImageView {
if let image = imageView.image {
Photor.one.saveImage(image)
}
}
}
func moViewDeleteTapped(moView: MoView) {
log("moViewDeleteTapped")
if let media = moView.media {
rlmDelete(media as! MediaR, ownerNote: note)
}
mediaViews.removeObject(moView)
moView.removeFromSuperview()
}
MoView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MoView"
hyouuu, hyouuu@gmail.com
MoView is available under the MIT license. See the LICENSE file for more info.