Commit 46681675 authored by huanglu's avatar huanglu

image load

parent 78be5a85
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'GeekImageEditor' s.name = 'GeekImageEditor'
s.version = '1.1' s.version = '1.2'
s.summary = 'Image Editor supports drawing, writing text and adding stickers and emojis' s.summary = 'Image Editor supports drawing, writing text and adding stickers and emojis'
s.description = <<-DESC s.description = <<-DESC
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
DCB129AF23FED085008C6FBD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DCB1298C23FED085008C6FBD /* LaunchScreen.storyboard */; }; DCB129AF23FED085008C6FBD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DCB1298C23FED085008C6FBD /* LaunchScreen.storyboard */; };
DCB129B023FED085008C6FBD /* PhotoEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCB1298D23FED085008C6FBD /* PhotoEditorViewController.swift */; }; DCB129B023FED085008C6FBD /* PhotoEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCB1298D23FED085008C6FBD /* PhotoEditorViewController.swift */; };
DCB129B223FED1BC008C6FBD /* Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCB129B123FED1BC008C6FBD /* Util.swift */; }; DCB129B223FED1BC008C6FBD /* Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCB129B123FED1BC008C6FBD /* Util.swift */; };
DCB129D223FFA5BB008C6FBD /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCB129D123FFA5BB008C6FBD /* SceneDelegate.swift */; };
F4B9A0836D32C4415F7FB205 /* Pods_GeekImageEditor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 341481C6D3A77817973EF5D1 /* Pods_GeekImageEditor.framework */; }; F4B9A0836D32C4415F7FB205 /* Pods_GeekImageEditor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 341481C6D3A77817973EF5D1 /* Pods_GeekImageEditor.framework */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
...@@ -123,6 +124,7 @@ ...@@ -123,6 +124,7 @@
DCB1298C23FED085008C6FBD /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; }; DCB1298C23FED085008C6FBD /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
DCB1298D23FED085008C6FBD /* PhotoEditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoEditorViewController.swift; sourceTree = "<group>"; }; DCB1298D23FED085008C6FBD /* PhotoEditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoEditorViewController.swift; sourceTree = "<group>"; };
DCB129B123FED1BC008C6FBD /* Util.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Util.swift; sourceTree = "<group>"; }; DCB129B123FED1BC008C6FBD /* Util.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Util.swift; sourceTree = "<group>"; };
DCB129D123FFA5BB008C6FBD /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -193,6 +195,7 @@ ...@@ -193,6 +195,7 @@
DCB1293A23FED058008C6FBD /* GeekImageEditor */ = { DCB1293A23FED058008C6FBD /* GeekImageEditor */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
DCB129D123FFA5BB008C6FBD /* SceneDelegate.swift */,
DCB1293B23FED058008C6FBD /* AppDelegate.swift */, DCB1293B23FED058008C6FBD /* AppDelegate.swift */,
DCB1293F23FED058008C6FBD /* ViewController.swift */, DCB1293F23FED058008C6FBD /* ViewController.swift */,
DCB1294123FED058008C6FBD /* Main.storyboard */, DCB1294123FED058008C6FBD /* Main.storyboard */,
...@@ -454,6 +457,7 @@ ...@@ -454,6 +457,7 @@
DCB129AE23FED085008C6FBD /* GradientView.swift in Sources */, DCB129AE23FED085008C6FBD /* GradientView.swift in Sources */,
DCB1298F23FED085008C6FBD /* PhotoEditor+Controls.swift in Sources */, DCB1298F23FED085008C6FBD /* PhotoEditor+Controls.swift in Sources */,
DCB1299023FED085008C6FBD /* ColorsCollectionViewDelegate.swift in Sources */, DCB1299023FED085008C6FBD /* ColorsCollectionViewDelegate.swift in Sources */,
DCB129D223FFA5BB008C6FBD /* SceneDelegate.swift in Sources */,
DCB1299723FED085008C6FBD /* ResizeControl.swift in Sources */, DCB1299723FED085008C6FBD /* ResizeControl.swift in Sources */,
DCB129A423FED085008C6FBD /* ColorCollectionViewCell.swift in Sources */, DCB129A423FED085008C6FBD /* ColorCollectionViewCell.swift in Sources */,
DCB129AD23FED085008C6FBD /* PhotoEditor+Font.swift in Sources */, DCB129AD23FED085008C6FBD /* PhotoEditor+Font.swift in Sources */,
......
...@@ -128,21 +128,17 @@ public final class PhotoEditorViewController: UIViewController { ...@@ -128,21 +128,17 @@ public final class PhotoEditorViewController: UIViewController {
func loadImageForPath(path: String) { func loadImageForPath(path: String) {
if let imgUrl = URL(string: path) { if let imgUrl = URL(string: path) {
self.imageView.kf.setImage(with: imgUrl, placeholder: nil, options: nil, progressBlock: nil, completionHandler: { (res) in self.imageView.kf.setImage(with: imgUrl)
switch res {
case .success(let success):
self.setImageView(image: success.image)
default:
break
}
})
} }
} }
func setImageView(image: UIImage) { func setImageView(image: UIImage?) {
imageView.image = image imageView.image = image
let size = image.suitableSize(widthLimit: UIScreen.main.bounds.width) if image != nil {
imageViewHeightConstraint.constant = (size?.height)! let size = image!.suitableSize(widthLimit: UIScreen.main.bounds.width)
imageViewHeightConstraint.constant = (size?.height)!
}
print("image", image)
} }
func hideToolbar(hide: Bool) { func hideToolbar(hide: Bool) {
...@@ -151,6 +147,11 @@ public final class PhotoEditorViewController: UIViewController { ...@@ -151,6 +147,11 @@ public final class PhotoEditorViewController: UIViewController {
bottomToolbar.isHidden = hide bottomToolbar.isHidden = hide
bottomGradient.isHidden = hide bottomGradient.isHidden = hide
} }
public override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
setImageView(image: self.imageView.image)
}
} }
extension PhotoEditorViewController: ColorDelegate { extension PhotoEditorViewController: ColorDelegate {
......
//
// SceneDelegate.swift
// GeekImageEditor
//
// Created by wenjindu on 2020/2/20.
// Copyright © 2020 wenjindu. All rights reserved.
//
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
@available(iOS 13.0, *)
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}
@available(iOS 13.0, *)
func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
}
@available(iOS 13.0, *)
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
@available(iOS 13.0, *)
func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
}
...@@ -18,7 +18,7 @@ class ViewController: UIViewController { ...@@ -18,7 +18,7 @@ class ViewController: UIViewController {
@IBAction func tapBtnAction(_ sender: Any) { @IBAction func tapBtnAction(_ sender: Any) {
let photo = PhotoEditorViewController.init(nibName: "PhotoEditorViewController", bundle: nil) let photo = PhotoEditorViewController.init(nibName: "PhotoEditorViewController", bundle: nil)
photo.imgPath = "http://a4.att.hudong.com/44/71/01300001009299133077717708025.jpg" photo.imgPath = "http://pics4.baidu.com/feed/e824b899a9014c08545e5585620d360e7bf4f421.jpeg?token=da3dd6b6e506335f742d3378e63012e1&s=92397E87D273FBD4441589A503006003"
photo.modalPresentationStyle = .fullScreen photo.modalPresentationStyle = .fullScreen
present(photo, animated: true, completion: nil) present(photo, animated: true, completion: nil)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment