Skip to content

Instantly share code, notes, and snippets.

@tony0x59
tony0x59 / GradientView.m
Last active December 17, 2015 18:19
iOS UIView 渐变色绘制
//
// GradientView.m
// GradientDemo
//
// Created by Tony Kong on 13-5-26.
// Copyright (c) 2013年 Tony Kong. All rights reserved.
//
#import "GradientView.h"
@tony0x59
tony0x59 / UIColor+CreateMethod.h
Last active December 19, 2015 01:19
UIColor便捷设置
#define UIColorFromHexRGB(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]
#define UIColorFrom8BitRGB(r, g, b) [UIColor \
colorWithRed:(r)/255.0 \
green:(g)/255.0 \
blue:(b)/255.0 alpha:1.0]
@tony0x59
tony0x59 / setUIViewAlpha.m
Last active December 21, 2015 22:19
设置本UIView透明,但子视图不受影响(不透明)
self.backgroundColor = [[UIColor darkGrayColor] colorWithAlphaComponent:0.85];
@tony0x59
tony0x59 / moveInAnimateUIView.m
Last active December 21, 2015 22:19
从顶部弹出视图的动画效果,当退出视图时调用[self leaveView]将视图弹出。
#pragma mark - UIAnimation
- (void)willMoveToSuperview:(UIView *)newSuperview
{
[self enterView];
}
#define ANIMATE_DURATION 0.3
- (void)enterView
{
@tony0x59
tony0x59 / UITableView+reloadDataAnimated.m
Created August 31, 2013 06:31
tableview重载数据时的淡入淡出动画过渡效果
#import "UITableView+reloadDataAnimated.h"
@implementation UITableView (reloadDataAnimated)
- (void)reloadDataWithAnimated:(BOOL)animated
{
[self reloadData];
if (animated) {
CATransition *animation = [CATransition animation];
@tony0x59
tony0x59 / .gitignore
Created March 27, 2014 05:11
.gitignore file for iOS dev
# from: https://github.com/github/gitignore/blob/master/Global/Xcode.gitignore
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
@tony0x59
tony0x59 / NSObject+SafeCategory.m
Last active July 19, 2017 23:15
使用Method swizzling方法修改常用函数行为
//
// NSObject+SafeCategory.m
//
// Created by Tony on 14-4-3.
// Copyright (c) 2014年 Tony. All rights reserved.
//
#import "NSObject+SafeCategory.h"
#import <JRSwizzle/JRSwizzle.h>
@tony0x59
tony0x59 / nginx.conf
Created April 23, 2014 09:53
Nginx RTMP Configure
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@tony0x59
tony0x59 / UITableView+CellForPressedButton.m
Created April 28, 2014 07:54
用于替代DirtyHack([[sender superview] superview])
#import "UITableView+CellForPressedButton.h"
@implementation UITableView (CellForPressedButton)
- (NSIndexPath*)indexPathForPressedButton:(UIView*)button
{
CGPoint buttonPosition = [button convertPoint:CGPointZero toView:self];
NSIndexPath *indexPath = [self indexPathForRowAtPoint:buttonPosition];
return indexPath;
}
@tony0x59
tony0x59 / 0_reuse_code.js
Created May 31, 2014 10:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console