Skip to content

Instantly share code, notes, and snippets.

@lipka
lipka / gist:9429277
Last active August 29, 2015 13:57
LinkAttributes on MonoTouch.TTTAttributedLabel
TTTAttributedLabel _notesLabel = new TTTAttributedLabel ();
NSMutableParagraphStyle paragraphStyle = new NSMutableParagraphStyle ();
paragraphStyle.Alignment = UITextAlignment.Center;
_notesLabel.LinkAttributes = new NSMutableDictionary () {
{ UIStringAttributeKey.ParagraphStyle, paragraphStyle },
{ UIStringAttributeKey.ForegroundColor, UIColor.Blue },
};
@lipka
lipka / gist:a01a8937bf945b573148
Created August 7, 2014 23:00
Enable slow iOS animations
p [(CALayer *)[[[[UIApplication sharedApplication] windows] objectAtIndex:0] layer] setSpeed:.1f]
### Keybase proof
I hereby claim:
* I am lipka on github.
* I am lipka (https://keybase.io/lipka) on keybase.
* I have a public key whose fingerprint is 2C91 1727 8671 72B4 AB89 9A77 B8B1 4F9F 21BD 0CDC
To claim this, I am signing this object:
//
// Copyright (c) 2013-2015 Frank A. Krueger
//
// 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
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
@lipka
lipka / FCPrivateBatteryStatus.m
Created February 5, 2016 17:32
How to get raw battery info (mAh remaining, etc.) from iOS using private APIs. For internal testing only, NOT APP STORE DISTRIBUTION!
#import <Foundation/Foundation.h>
#include <dlfcn.h>
NSDictionary *FCPrivateBatteryStatus()
{
static mach_port_t *s_kIOMasterPortDefault;
static kern_return_t (*s_IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options);
static mach_port_t (*s_IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching CF_RELEASES_ARGUMENT);
static CFMutableDictionaryRef (*s_IOServiceMatching)(const char *name);
@lipka
lipka / PSPDFUIKitMainThreadGuard.m
Created April 26, 2016 22:43 — forked from steipete/PSPDFUIKitMainThreadGuard.m
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.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@lipka
lipka / TabComponent.swift
Created August 11, 2016 21:33 — forked from irace/TabComponent.swift
Easily roll your own `UITabBarController` alternatives. Here’s all the logic you need without assuming anything about your UI.
/**
* A class that can be part of a tabbed navigational interface (expected to be a `UIViewController` but can also be a
* coordinator that proxies through to an underlying controller).
*/
public protocol TabComponent {
/// The tab metadata
var tabItem: TabItem { get }
var viewController: UIViewController { get }
}
@lipka
lipka / gist:891a274b47b2877e8ce434e4d215898c
Created July 9, 2017 12:36 — forked from steipete/ios-xcode-device-support.sh
Using iOS 10.3 devices with Xcode 8.2.1
// The trick is to link the DeviceSupport folder from the beta to the stable version.
// Updated on Jan 24th, 2017 for Xcode 8.3b1
ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/10.3\ \(14E5230d\)/ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
// Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
// sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
// Created by Caleb Davenport on 7/14/17.
import UIKit
final class ActionSheetPresentationController: UIPresentationController {
// MARK: - Properties
private var dimmingView: UIView!
import UIKit
// This class allows the "presentedController" to receive touches
// https://pspdfkit.com/blog/2015/presentation-controllers/
class PSPDFTouchForwardingView: UIView {
var passthroughViews: [UIView] = []
override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {
guard let hitView = super.hitTest(point, withEvent: event) else { return nil }