Skip to content

Instantly share code, notes, and snippets.

View BetrayalPromise's full-sized avatar

桃花影落飞神剑 碧海潮生暗玉箫 BetrayalPromise

View GitHub Profile
@BetrayalPromise
BetrayalPromise / UIView+ModifyFrame.h
Created April 19, 2016 08:17 — forked from bobmoff/UIView+ModifyFrame.h
Simple but really useful category on UIView that makes modifying the frame NOT hellish. Published under WTFPL [http://www.wtfpl.net/]. Usage example can be found in the comments
/*
Before:
CGRect frame = myView.frame;
frame.origin.x = newX;
myView.frame = frame;
After:
myView.x = newX;
@BetrayalPromise
BetrayalPromise / CGRect+Additions.h
Created April 19, 2016 08:17 — forked from aegzorz/CGRect+Additions.h
Some functions for dealing with CGRects
static __inline__ CGRect CGRectFromCGSize( CGSize size ) {
return CGRectMake( 0, 0, size.width, size.height );
};
static __inline__ CGRect CGRectMakeWithCenterAndSize( CGPoint center, CGSize size ) {
return CGRectMake( center.x - size.width * 0.5, center.y - size.height * 0.5, size.width, size.height );
};
static __inline__ CGRect CGRectMakeWithOriginAndSize( CGPoint origin, CGSize size ) {
return CGRectMake( origin.x, origin.y, size.width, size.height );
@BetrayalPromise
BetrayalPromise / NSArray+FirstObject.h
Created April 19, 2016 08:15 — forked from aegzorz/NSArray+FirstObject.h
Gets the first object in an array or returns nil for empty array.
//
// NSArray+FirstObject.h
//
#import <Foundation/Foundation.h>
@interface NSArray (FirstObject)
- (id)firstObject;
@BetrayalPromise
BetrayalPromise / NSString+Extensions.h
Created April 19, 2016 08:14 — forked from Abeansits/NSString+Extensions.h
A utility box for NSStrings. Converts to: SHA1, NSNumber. Test for being empty. Contains substrings and replace substrings from NSDictionary.
#import <Foundation/Foundation.h>
@interface NSString (Extensions)
+ (NSString *)stringToSha1:(NSString *)str;
- (NSNumber*)stringToNSNumber;
- (BOOL)isEmpty;
- (BOOL)stringContainsSubString:(NSString *)subString;
- (NSString *)stringByReplacingStringsFromDictionary:(NSDictionary *)dict;
@BetrayalPromise
BetrayalPromise / UILabel+dynamicSizeMe.h
Created April 19, 2016 08:11 — forked from danielphillips/UILabel+dynamicSizeMe.h
Adjust UILabel to change it's frame according to it's content
@interface UILabel (dynamicSizeMe)
-(float)resizeToFit;
-(float)expectedHeight;
@end
@BetrayalPromise
BetrayalPromise / UIView+Stacker.h
Created April 19, 2016 08:10 — forked from bobmoff/UIView+Stacker.h
Stack subviews vertically ordered by their index. Good when u want to use XIB's and need to layout views (show/hide) based on external data, but cannot use autolayout.
#import <UIKit/UIKit.h>
@interface UIView (Stacker)
- (void)stackSubviews;
@end
@BetrayalPromise
BetrayalPromise / UIView+RoundedCorners.h
Created April 19, 2016 08:10 — forked from bobmoff/UIView+RoundedCorners.h
Add rounded corners to any view using layer mask.
#import <UIKit/UIKit.h>
@interface UIView (RoundedCorners)
- (void)setRoundedCorners:(UIRectCorner)corners radius:(CGSize)size;
@end
@BetrayalPromise
BetrayalPromise / UIView+Recursion.h
Created April 19, 2016 08:09 — forked from aegzorz/UIView+Recursion.h
Recursively find a subview.
#import <UIKit/UIKit.h>
@interface UIView (Recursion)
/**
Return YES from the block to recurse into the subview.
Set stop to YES to return the subview.
*/
- (UIView*)findViewRecursively:(BOOL(^)(UIView* subview, BOOL* stop))recurse;
@BetrayalPromise
BetrayalPromise / NSObject+LogDealloc.h
Created April 19, 2016 08:07 — forked from aegzorz/NSObject+LogDealloc.h
Category on NSObject that logs deallocs, useful when tracking down memory leaks
#import <Foundation/Foundation.h>
@interface NSObject (LogDealloc)
- (void)logOnDealloc;
@end
@BetrayalPromise
BetrayalPromise / NSHTTPCookieStorage+FreezeDry.h
Created April 19, 2016 08:06 — forked from maciekish/NSHTTPCookieStorage+FreezeDry.h
Persists UIWebView cookies to disk. To send the cookies with an initial NSURLRequest you must do the following after loading the cookies: NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:yourURL]; NSDictionary* headers = [NSHTTPCookie requestHeaderFieldsWithCookies:[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]]; [requ…
//
// NSHTTPCookieStorage+FreezeDry.h
//
// Created by Maciej Swic on 19/08/13.
//  
// 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