Skip to content

Instantly share code, notes, and snippets.

@alloy
alloy / FTAccessibleActionSheet.m
Created May 3, 2011 13:28
A UIActionSheet subclass that customizes the accessibility labels of the options in the sheet.
// Copyright (c) 2011 Eloy Durán <eloy@fngtps.com>
// Available under the MIT license: http://www.opensource.org/licenses/mit-license.php
#import <objc/message.h>
@interface FTAccessibleActionSheet : UIActionSheet
- (void)copyAccessibilityMetadataFrom:(NSString *)title toControl:(UIView *)control;
@end
@implementation FTAccessibleActionSheet
@mbinna
mbinna / UIViewController+MBSensitiveInformationInScreenshotPrevention.h
Created June 12, 2011 13:00
Prevent sensitive information from appearing in the screenshot that is automatically taken when the application transitions from the foreground to the background and vice-versa.
//
// UIViewController+MBSensitiveInformationInScreenshotPrevention.h
//
// Created by Manuel Binna on 05.05.11.
// Copyright 2011 Manuel Binna. All rights reserved.
//
@interface UIViewController (MBSensitiveInformationInScreenshotPrevention)
@nevyn
nevyn / SPAppearance.h
Created February 6, 2012 15:39
Make UIButtons from images with a single line
@interface SPAppearance : NSObject
+(id)sharedAppearance;
/** return a button with [name].png for normal, [name]-highlighted.png for highlight state,
[name]-selected.png for selected and [name]-disabled.png for disabled, and combinations thereof.
If the image conforms to configuredImageNamed, its 9-part configuration will be used for the button,
and its title insets configured appropriately.
*/
-(UIButton*)buttonWithImageNamed:(NSString*)name;
@radianttap
radianttap / gist:4484269
Last active December 10, 2015 19:48 — forked from anonymous/gist:4468522
Pulse view
+ (void)pulseView:(UIView *)view completion:(void (^)(void))block {
// if you use auto layout, view-based transform go haywire, as they trigger layoutSubviews
// consequence is that you have no idea where the view will end up on the screen once animation completes
// see this discussion: http://stackoverflow.com/questions/12943107/how-do-i-adjust-the-anchor-point-of-a-calayer-when-auto-layout-is-being-used
// thus (per solution 4 from link above), rewriting with CAKeyframeAnimation
CAKeyframeAnimation *ka = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
ka.duration = .49;
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active May 27, 2024 12:11
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@boredzo
boredzo / wwdc2013index-redacted.txt
Last active December 18, 2015 12:59
Script to rename WWDC videos and slides PDFs to include the session title in the name. Also included: A list of the session numbers and (redacted where necessary) titles, in TSV format, for use with this script.
100 Keynote
101 Platforms State of the Union
102 Apple Design Awards
109 Painting the Future
200 Accessibility in OS X
201 Building User Interfaces for iOS 7
202 Accessibility in iOS
203 What’s New in Cocoa Touch
204 What’s New with Multitasking
205 What’s New in Cocoa
@lisamelton
lisamelton / transcode-video.sh
Last active May 24, 2024 17:42
Transcode video file (works best with Blu-ray or DVD rip) into MP4 (or optionally Matroska) format, with configuration and at bitrate similar to popular online downloads.
#!/bin/bash
#
# transcode-video.sh
#
# Copyright (c) 2013-2015 Don Melton
#
about() {
cat <<EOF
$program 5.13 of April 8, 2015
@fastred
fastred / gist:96f3829ed676ed599aeb
Last active August 29, 2015 14:03
NSProgress.markdown

Cleaned up results of running ack NSProgress ./ in

  • /Applications/Xcode6-Beta3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks
  • /Applications/Xcode6-Beta3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks

iOS:

CoreData.framework/Headers/NSPersistentStoreResult.h:10:@class NSProgress;
CoreData.framework/Headers/NSPersistentStoreResult.h:33:    NSProgress* _requestProgress;
CoreData.framework/Headers/NSPersistentStoreResult.h:42:@property (strong, readonly) NSProgress* progress;
@kaishin
kaishin / snapshot.swift
Created January 10, 2016 14:29
NSView Snapshot
extension NSView {
var snapshot: NSImage {
guard let bitmapRep = bitmapImageRepForCachingDisplayInRect(bounds) else { return NSImage() }
bitmapRep.size = bounds.size
cacheDisplayInRect(bounds, toBitmapImageRep: bitmapRep)
let image = NSImage(size: bounds.size)
image.addRepresentation(bitmapRep)
return image
}
}
@jrturton
jrturton / testimage.swift
Created November 19, 2018 14:59
Make a date-stamped test image
let renderer = UIGraphicsImageRenderer(size: CGSize(width: 400, height: 400))
let image = renderer.image {
context in
UIColor.lightGray.setFill()
UIRectFill(context.format.bounds)
UIColor.black.set()
UIRectFrame(context.format.bounds)
let text = "TEST IMAGE \n\(Date())" as NSString
let paragraph = NSMutableParagraphStyle()
paragraph.alignment = .center