Skip to content

Instantly share code, notes, and snippets.

/* Usage:
// This is in your viewcontroller, which implements UINavigationControllerDelegate
func navigationController(navigationController: UINavigationController, willShowViewController: UIViewController, animated: Bool) {
if isImageViewer(navigationController) {
addCircleOverlayToImageViewer(willShowViewController)
}
}
*/
func isImageViewer(navigationController: UINavigationController) -> Bool {
@yuvalt
yuvalt / UIImage+crop.swift
Last active January 30, 2016 03:53
Extension of UIImage the helps cropping an image with an example of how to use the result of UIImagePickerController. Credit: original Objective-C code: http://blog.cmgresearch.com/2012/07/14/Cropping-the-results-from-UIImagePickerController.html
/*
Usage example:
// MARK - UIImagePickerControllerDelegate
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
let cropRect = info[UIImagePickerControllerCropRect]?.CGRectValue
let croppedImage = pickedImage.crop(cropRect)
self.anImage.contentMode = .ScaleAspectFit
@yuvalt
yuvalt / UITextView+Placeholder.swift
Last active September 12, 2020 08:33 — forked from tijme/UITextViewPlaceholder.swift
The correct way to implement a placeholder in a UITextView (Swift). Allow the user to control the text, color, font and position of the placeholder. Everything (but font) can be modified from within Interface Builder.
//
// UITextViewPlaceholder.swift
// TextViewPlaceholder
//
// Original work Copyright (c) 2017 Tijme Gommers <[email protected]>
// Modified work Copyright (c) 2017 Yuval Tal <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights