Skip to content

Instantly share code, notes, and snippets.

UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.translatesAutoresizingMaskIntoConstraints = NO;
button1.backgroundColor = [UIColor greenColor];
[button1 setTitle:@"button1" forState:UIControlStateNormal];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
button2.translatesAutoresizingMaskIntoConstraints = NO;
button2.backgroundColor = [UIColor redColor];
[button2 setTitle:@"button2" forState:UIControlStateNormal];
@mcmurrym
mcmurrym / gist:4b8c81e9214d00a20727
Created May 4, 2015 21:38
How to Check the "Allow app extension API only" of pod frameworks.
post_install do |installer|
installer.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'YES'
end
end
end
@mcmurrym
mcmurrym / UIViewIBLayoutMarginSupport.swift
Last active August 29, 2015 14:21
Add Layout margin controls to IB. I hope Apple eventually integrates a layoutMargin attribute control into IB, until then this should do the trick. Just drop it in to your project and it should show up in IB. For iOS 8.0 and up
// UIViewIBLayoutMarginSupport.swift
// Created by Matt McMurry on 5/26/15.
import UIKit
public extension UIView {
@IBInspectable public var leftLayoutMagrin: CGFloat {
set {
var margins = layoutMargins
margins.left = newValue
@mcmurrym
mcmurrym / MirrorDebugDecscription.swift
Last active October 3, 2024 14:09
A default protocol implementation for CustomDebugStringConvertible that uses Mirror for introspection
public extension CustomDebugStringConvertible {
var debugDescription: String {
return debugDescription()
}
func debugDescription(_ indentationLevel: Int = 0, includeType: Bool = true) -> String {
let indentString = (0..<indentationLevel).reduce("") { tabs, _ in tabs + "\t" }
var s: String
iPad 9.7 inch
Portrait
.large
minimumInteritemSpacing: 40.0
minimumLineSpacing: 30.0
sectionInset: UIEdgeInsets(top: 7.0, left: 35.0, bottom: 7.0, right: 35.0)
itemSize: (206.0, 206.0)
@mcmurrym
mcmurrym / evaluate.m
Created December 18, 2017 23:09
NSExpression works great on the simulator and does not work on the device when using %@ and/or stringByAppendingFormat:
- (void)evaluate {
NSExpression *expression = [NSExpression expressionWithFormat:@"FUNCTION(source.firstName, 'stringByAppendingFormat:', ' %@', source.lastName)"];
NSDictionary *expressionObject = @{NSMigrationSourceObjectKey: @{@"firstName": @"tacos", @"lastName": @"burger"}};
id result = [expression expressionValueWithObject:expressionObject context:nil];
NSLog(@"%@", result);
}
//on simulator: "tacos burgers"
//on device: "tacos %@"
@mcmurrym
mcmurrym / TestRepeater.swift
Created January 31, 2019 18:30
Repeat a test till it fails. This can be used to help troubleshoot tests with intermittent failures and to grow confidence in the code being tested or the test itself, being fixed
#!/usr/bin/swift
import Foundation
class TestRepeater {
func runTest() {
let result = shell("/usr/bin/xcodebuild", [
"-project", "PSKit.xcodeproj",
"-scheme", "PSKit",
"test-without-building",
@mcmurrym
mcmurrym / pods_mac_catalyst.rb
Last active August 16, 2019 21:32
Load this file at the top of your Podfile `load 'pods_mac_catalyst.rb'` in your post_install function call this: adjust_pod_installation_for_mac_catalyst(installer, [pods_with_bundles], 'dev team idea to assign to pod bundles')
# frozen_string_literal: true
require 'set'
def adjust_pod_installation_for_mac_catalyst(installer, resource_bundles_needing_dev_team, team_id)
puts('Updating Pod Configuration To Support Mac Catalyst')
exclusions = scan_for_exclusions(installer)
update_xcconfig(installer, exclusions)
update_frameworks_script(installer, exclusions)
disable_mac_catalyst_build_setting(installer.pods_project.targets, exclusions)