Skip to content

Instantly share code, notes, and snippets.

@FahimF
FahimF / SimpleStackView.swift
Last active October 19, 2020 14:23
A UIStackView implementation of UIListContentConfiguration and UIListContentView
import UIKit
class SimpleStackView: UIViewController {
private var scrollView: UIScrollView!
private var stackView: UIStackView!
override func viewDidLoad() {
super.viewDidLoad()
// View title
title = "Books - Stack"
@FahimF
FahimF / SimpleCollectionView.swift
Last active December 13, 2022 00:52
A UICollectionView implementation of UIListContentConfiguration
import UIKit
class SimpleCollectionView: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
private var collectionView: UICollectionView!
private var cellRegistration: UICollectionView.CellRegistration<UICollectionViewListCell, Book>!
override func viewDidLoad() {
super.viewDidLoad()
// View title
title = "Books - Collection"
@FahimF
FahimF / SimpleTableView.swift
Last active October 19, 2020 14:04
A UITableView implementation of UIListContentConfiguration
import UIKit
class SimpleTableView: UIViewController, UITableViewDelegate, UITableViewDataSource {
private var tableView: UITableView!
private let reuseIdentifier = "BookCell"
override func viewDidLoad() {
super.viewDidLoad()
// View title
title = "Books - Table"
@FahimF
FahimF / Book.swift
Last active October 19, 2020 14:03
Book model for use with UIListContentConfiguration examples
import Foundation
enum AuthorType {
case single, multiple
}
struct Book: Hashable {
var title = ""
var author = ""
var pages = 0
@FahimF
FahimF / Example.m
Created May 29, 2012 13:37
A basic nine-grid sprite node for Cocos2D. You set the contentSize property of the sprite and it will do the layout automatically. The layout also respects the anchorPoint property so it's easy to align the sprites however you want.
CCSprite *sprite = [CCSprite spriteWithFile:@"button9grid.png"];
NGNineGridSprite *nineGrid = [NGNineGridSprite spriteWithSpriteFrame:sprite.displayFrame andCornerSize:CGSizeMake(10, 10)];
nineGrid.position = ccp(160, 240);
nineGrid.anchorPoint = ccp(0.5, 0.5);
nineGrid.contentSize = CGSizeMake(150, 150);
[self addChild:nineGrid];
@FahimF
FahimF / gist:2707734
Created May 16, 2012 05:31 — forked from ironfounderson/gist:661556
UIViewController using blocks
@class BookViewController;
typedef void(^BookViewControllerResponse)(BookViewController *controller);
@interface BookViewController : UIViewController {
BookViewControllerResponse cancelBlock_;
BookViewControllerResponse saveBlock_;
}
@property (nonatomic, copy) BookViewControllerResponse cancelBlock;
@FahimF
FahimF / UIColor+Addition.m
Created May 16, 2012 05:29 — forked from jinthagerman/UIColor+Addition.m
UIColor from hex
// http://stackoverflow.com/questions/1560081/how-can-i-create-a-uicolor-from-a-hex-string
+ (UIColor *) colorWithHex:(int)hex {
return [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0
green:((float)((hex & 0xFF00) >> 8))/255.0
blue:((float)(hex & 0xFF))/255.0 alpha:1.0];
}