This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For UIViewController inside UINavigationController | |
- (void)viewWillLayoutSubviews | |
{ | |
[super viewWillLayoutSubviews]; | |
self.navigationController.view.superview.bounds = CGRectMake(0, 0, 300, 300); | |
self.navigationController.view.superview.layer.cornerRadius = 2.0f; | |
} | |
// Usual presentation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class func drawHollowCircle(circleColor: UIColor, rect: CGRect, startAngle: CGFloat = 1, endAngle: CGFloat = 360, outerRingProportion: CGFloat = 1, innerRingProportion: CGFloat = 0.5, drawShadow : Bool) { | |
//// Variable Declarations | |
let startAngleCalced: CGFloat = -startAngle + 270 | |
let endAngleCalced: CGFloat = -endAngle + 270 | |
let innerRingDiameter: CGFloat = rect.size.width * innerRingProportion | |
let innerRingOffset: CGFloat = 0.5 * (rect.size.width - innerRingDiameter) | |
let innerRingRect = CGRectMake(innerRingOffset, innerRingOffset, innerRingDiameter, innerRingDiameter) | |
let outerRingDiameter: CGFloat = rect.size.width * outerRingProportion | |
let outerRingOffset: CGFloat = 0.5 * (rect.size.width - outerRingDiameter) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MakeTransparentHoleOnOverlayView.swift | |
// | |
// Created by James Laurenstin on 2015-04-10. | |
// Copyright (c) 2015 Aldo Group Inc. All rights reserved. | |
// | |
import UIKit | |
class MakeTransparentHoleOnOverlayView: UIView { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIImage { | |
subscript (x: Int, y: Int) -> UIColor? { | |
guard x >= 0 && x < Int(size.width) && y >= 0 && y < Int(size.height), | |
let cgImage = cgImage, | |
let provider = cgImage.dataProvider, | |
let providerData = provider.data, | |
let data = CFDataGetBytePtr(providerData) else { | |
return nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config: | |
FunctionName: aws-lambda-aes-gist | |
Handler: index.handler | |
Runtime: nodejs | |
Description: A Lambda function for AES encryption/decryption, from a Gist! | |
install: npm install --production |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// Timeout wrapps a callback deferral that may be cancelled. | |
/// | |
/// Usage: | |
/// Timeout(1.0) { println("1 second has passed.") } | |
/// | |
class Timeout: NSObject | |
{ | |
private var timer: NSTimer? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(UIImage*) cropCameraImage:(UIImage*) original toPreviewLayerBounds:(AVCaptureVideoPreviewLayer*) previewLayer { | |
UIImage *ret = nil; | |
CGRect previewImageLayerBounds = previewLayer.bounds; | |
// This calculates the crop area. | |
// keeping in mind that this works with on an unrotated image (so a portrait image is actually rotated counterclockwise) | |
// thats why we use originalHeight to calculate the width | |
float originalWidth = original.size.width; | |
float originalHeight = original.size.height; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by ddrccw on 14-1-10. | |
// Copyright (c) 2014年 ddrccw. All rights reserved. | |
// refer to http://danqingdani.blog.163.com/blog/static/1860941952012102122847478/ | |
#import <sys/stat.h> | |
#import <mach-o/dyld.h> | |
//#import <stdlib.h> | |
//#import <string.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation UITextView (Annex) | |
@dynamic visibleTextRange; | |
- (NSRange)visibleTextRange | |
{ | |
CGRect bounds = self.bounds; | |
CGSize textSize = [self.text sizeWithFont:self.font constrainedToSize:bounds.size]; | |
UITextPosition *start = [self characterRangeAtPoint:bounds.origin].start; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)compressImage:(UIImage *)image{ | |
float actualHeight = image.size.height; | |
float actualWidth = image.size.width; | |
float maxHeight = 600.0; | |
float maxWidth = 800.0; | |
float imgRatio = actualWidth/actualHeight; | |
float maxRatio = maxWidth/maxHeight; | |
float compressionQuality = 0.5;//50 percent compression | |
if (actualHeight > maxHeight || actualWidth > maxWidth) { |