Skip to content

Instantly share code, notes, and snippets.

import Foundation
import UIKit
import AVFoundation
class ClassImageEditingView:UIView{
var context: CGContext?
var contextBounds = CGRect.zero
@hindalsayyar
hindalsayyar / Enable Touch for SubView with gesture
Created April 9, 2019 13:52
Enable Touch for SubView When adding Gesture for parent view
import UIKit
class ViewController: UIViewController, UIGestureRecognizerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(printHello))
tapGestureRecognizer.delegate = self
view.addGestureRecognizer(tapGestureRecognizer)
@hindalsayyar
hindalsayyar / drawImageScaled
Created April 9, 2019 08:37
drawImageScaled
func drawImageScaled(_ image: UIImage?) {
print("we are scalling the drawing")
// just draws the image scaled down and centered
let selfRatio: CGFloat = frame.size.width / frame.size.height //change the size later
let imgRatio: CGFloat = (image?.size.width ?? 0.0) / (image?.size.height ?? 0.0)
var rect : CGRect
rect = CGRect(x: 0, y: 0, width: 0, height: 0)