Skip to content

Instantly share code, notes, and snippets.

View mrtj's full-sized avatar

Janos Tolgyesi mrtj

View GitHub Profile
@mrtj
mrtj / BouncyButtonViewController.h
Created February 19, 2014 10:56
iOS view controller demonstrating how to create a bouncy rubber button with the new UIView method animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion: of iOS 7
#import <UIKit/UIKit.h>
@interface BouncyButtonViewController : UIViewController
@end
@mrtj
mrtj / UIView+Blur.h
Created July 4, 2013 15:20
Create blurred image from any UIView #objective-c
#import <UIKit/UIKit.h>
@interface UIView (Blur)
+(UIImage*)createBlurredImageFromView:(UIView*)view;
@end
@mrtj
mrtj / NSURL+QueryParser.h
Created May 20, 2013 15:58
NSURL category to parser GET parameters from the URL into a NSDictionary #objective-c #utils #url
#import <Foundation/Foundation.h>
@interface NSURL (QueryParser)
-(NSDictionary*)queryDictionary;
@end
@mrtj
mrtj / UIColorFromRGB.h
Last active December 16, 2015 05:59
UIColor from 0x123456 style unsigned integer
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
@mrtj
mrtj / RectUtils.h
Last active December 15, 2015 05:49
Simple CGRect utils #core-graphics #objective-c #utils #cgrect
#ifndef RECTUTILS_H
#define RECTUTILS_H
#include <CoreGraphics/CGGeometry.h>
CG_INLINE CGRect CGRectChangeSize(CGRect rect, CGSize size);
CG_INLINE CGRect CGRectChangeWidth(CGRect rect, CGFloat width);
CG_INLINE CGRect CGRectChangeHeight(CGRect rect, CGFloat height);
CG_INLINE CGRect CGRectChangeOrigin(CGRect rect, CGPoint origin);
@mrtj
mrtj / TJXMLParser.h
Last active December 14, 2015 18:59
Simple DOM based XML parser #cocoa #xml #parser #utils #dom
#import <Foundation/Foundation.h>
@interface TJXMLElement : NSObject
@property (nonatomic, readonly) NSString* name;
@property (nonatomic, readonly) NSDictionary* attributes;
@property (nonatomic, retain) NSMutableArray* children;
@property (nonatomic, retain) NSMutableString* text;
- (id) initWithName:(NSString*)name withAttributes:(NSDictionary*)attributes;
@mrtj
mrtj / UIImageView+OfflineCache.h
Created March 6, 2013 09:18
UIImageView category to download images asynchronously using the cache policy of the HTTP server if it is reachable otherwise look up for the image resource in the local HTTP cache. Depends on AFNetworking UIImageView category and Reachability components. #utils #image #UIImageView #cache #http #download
#import <UIKit/UIKit.h>
@interface UIImageView (OfflineCache)
-(void)setImageCachedWithURL:(NSURL*)url
placeholderImage:(UIImage *)placeholderImage
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
@end
@mrtj
mrtj / TJSettingsManager.h
Last active December 14, 2015 04:39
A wrapper class around NSUserDefaults that adds compile time type and spell check to keys stored in user defaults. Usage: inherit from this class and define your properties in your header (currently only NSInteger and BOOL types are supported). In the implementation mark all properties as @dynamic much like in managed object derivates. All of yo…
#import <Foundation/Foundation.h>
@interface TJSettingsManager : NSObject
{
NSUserDefaults* _userDefaults;
}
+(id)sharedInstance;
-(void)save;
@mrtj
mrtj / UIImage+Retina4.h
Created February 15, 2013 11:56
Extends [UIImage imageNamed:] method to consider also -568h@2x suffices of images targeted for Retina 4" devices. #iOS #objective-c #retina #ui #utility
#import <UIKit/UIKit.h>
@interface UIImage (Retina4)
+ (UIImage *)imageNamedRetina4:(NSString *)imageName;
@end