Skip to content

Instantly share code, notes, and snippets.

//
// NSObject+Association.h
//
// Created by Maciej Swic on 03/12/13.
// Released under the MIT license.
//
#import <Foundation/Foundation.h>
@interface NSObject (Association)
- (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@SmallBlackCat
SmallBlackCat / UIVIew+Tree.h
Last active August 29, 2015 14:05
查看当前view tree结构
// Frome http://poolo.iteye.com/blog/1833821
#import <UIKit/UIKit.h>
@interface UIView (Tree)
- (void)logViewTreeForMainWindow;
@end
@SmallBlackCat
SmallBlackCat / .gitignore
Created August 19, 2014 09:22
git 忽略文件
# Mac OS X Finder and whatnot
.DS_Store
# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
@SmallBlackCat
SmallBlackCat / gist:4f6a468cbd4f80161cd3
Created August 14, 2014 09:27
Custom Navgaion Bar
// 配置自定义NavigationBar
- (void) setupCustomNavigaionBar
{
// iOS 7 or Later
if (is_IOS7OrLater) {
// 图片背景
[[UINavigationBar appearance] setBackgroundImage:[UIImage UIImageFromeColor:[UIColor colorWithRed:0.33 green:0.63 blue:0.7 alpha:1] withSize:CGSizeMake(0, 1)] forBarMetrics:UIBarMetricsDefault];
// 背景颜色
[[UINavigationBar appearance] setBarTintColor:Button_Backgroud_Color];
@SmallBlackCat
SmallBlackCat / CommonMacro.h
Last active August 30, 2016 07:34 — forked from ondev/gist:6714742
常用的IOS开发宏
//
// CommonMacro.h
//
//
// Created by Haven on 26/9/13.
// Copyright (c) 2013 LF. All rights reserved.
//
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>