Skip to content

Instantly share code, notes, and snippets.

Avatar

Cory D. Wiles kwylez

View GitHub Profile
@jordansinger
jordansinger / iPod.swift
Created Jul 27, 2020
Swift Playgrounds iPod Classic
View iPod.swift
import SwiftUI
import PlaygroundSupport
struct iPod: View {
var body: some View {
VStack(spacing: 40) {
Screen()
ClickWheel()
Spacer()
}
@nicklockwood
nicklockwood / Hacking UIView Animation Blocks.md
Last active Jun 30, 2021
This article was originally written for objc.io issue 12, but didn't make the cut. It was intended to be read in the context of the other articles, so if you aren't familiar with concepts such as CALayer property animations and the role of actionForKey:, read the articles in that issue first.
View Hacking UIView Animation Blocks.md

Hacking UIView animation blocks for fun and profit

In this article, I'm going to explore a way that we can create views that implement custom Core Animation property animations in a natural way.

As we know, layers in iOS come in two flavours: Backing layers and hosted layers. The only difference between them is that the view acts as the layer delegate for its backing layer, but not for any hosted sublayers.

In order to implement the UIView transactional animation blocks, UIView disables all animations by default and then re-enables them individually as required. It does this using the actionForLayer:forKey: method.

Somewhat strangely, UIView doesn't enable animations for every property that CALayer does by default. A notable example is the layer.contents property, which is animatable by default for a hosted layer, but cannot be animated using a UIView animation block.

@jverkoey
jverkoey / UIView Layout
Last active May 16, 2020
Layout + size calculations for iOS.
View UIView Layout
- (CGSize)sizeOfContentsWithSize:(CGSize)size
shouldLayout:(BOOL)shouldLayout {
// Calculate frames.
if (shouldLayout) {
// Update frames.
}
return // size
}
@nfarina
nfarina / UIView+FrameAdditions.h
Created Aug 21, 2012
UIView Frame helper getter/setter category methods
View UIView+FrameAdditions.h
#import <UIKit/UIKit.h>
@interface UIView (SMFrameAdditions)
@property (nonatomic, assign) CGPoint $origin;
@property (nonatomic, assign) CGSize $size;
@property (nonatomic, assign) CGFloat $x, $y, $width, $height; // normal rect properties
@property (nonatomic, assign) CGFloat $left, $top, $right, $bottom; // these will stretch the rect
@end
@steipete
steipete / ARCCheck.m
Created Dec 5, 2011
Don't be a fool and wonder why nothing is working... ADD THIS CHECK.
View ARCCheck.m
// ARC is compatible with iOS 4.0 upwards, but you need at least Xcode 4.2 with Clang LLVM 3.0 to compile it.
#if !defined(__clang__) || __clang_major__ < 3 || !__has_feature(objc_arc)
#error This project must be compiled with ARC (Xcode 4.2+ with LLVM 3.0 and above)
#endif
@stevestreza
stevestreza / NSURL+Pieces.h
Created Sep 26, 2011
A method for debugging NSURLs to find where the different pieces of your URL are
View NSURL+Pieces.h
#import <Foundation/Foundation.h>
@interface NSURL (Pieces)
-(NSDictionary *)piecesDictionary;
@end