Skip to content

Instantly share code, notes, and snippets.

@akinLiu
akinLiu / transform.m
Created June 18, 2012 05:59
放大缩小动画
[UIView animateWithDuration:0.1
animations:^{
self.testView.transform = CGAffineTransformMakeScale(1.2,1.2);
}
completion:^(BOOL finished) {
[UIView animateWithDuration:0.05
animations:^{
self.testView.transform = CGAffineTransformMakeScale(0.9,.9);
}
completion:^(BOOL finished) {
@akinLiu
akinLiu / package.sh
Created June 26, 2012 17:08 — forked from icyleaf/umeng_ios_publish_channel_package_tool.sh
iOS 友盟发布渠道自动化脚本
#
# iOS 友盟发布渠道自动化脚本
#
# - 在 Archive 的 "Post-action" 添加脚本去执行 "/bin/sh $SRCROOT/package.sh"
# - 确保在 "Provide build setting from" 选择了当前的 App
# - 在项目根目录($SRCROOT)添加 "iTunesArtwork" 文件(符合 App Store 提交要求的 512x512 px, PNG 格式)
# - 在下面 "" 设置你需要的发布渠道(空格分隔)
# - 在下面设置打包后的 ipa 的输出路径(可选)
# - 执行 "Product > Archive"
#
@akinLiu
akinLiu / showsystemFile
Created December 18, 2012 07:47
显示 隐藏 mac osx 系统文件
//显示系统文件
defaults write com.apple.finder AppleShowAllFiles -bool true
KillAll Finder
//隐藏系统文件
defaults write com.apple.finder AppleShowAllFiles -bool false
KillAll Finder
@akinLiu
akinLiu / Universal
Created December 24, 2012 16:39
判断设备类型
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSLog(@"ipad");
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
NSLog(@"iphone");
}
@akinLiu
akinLiu / IS_IPHONE5
Created March 18, 2013 08:43
判断iphone 5
#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
<?php
/**
* img.ly class for Kohana v3.0.x
*
* @author icyleaf <icyleaf.cn@gmail.com>
* @link http://icyleaf.com
* @version 0.1
* @license http://www.opensource.org/licenses/bsd-license.php
*/
class imgly {
@akinLiu
akinLiu / UIViewToImage
Created July 13, 2013 03:12
UIView to UIImage
- (UIImage*)toImage
{
UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0.0);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
// Photoshop Script to Create iPhone Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
// Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com
@akinLiu
akinLiu / checkRecordPermission
Created May 20, 2014 15:26
检测麦克风可用状态
if ([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission:)]) {
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
if (!granted) {
//检测到不可用
dispatch_async(dispatch_get_main_queue(), ^{
//回到主线程做出相应提示
});
}
}];
}
@akinLiu
akinLiu / sorted
Created June 9, 2014 15:40
多条件排序
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSSortDescriptor *descriptor1 = [[NSSortDescriptor alloc] initWithKey:@"endCalYear" ascending:YES];
NSSortDescriptor *descriptor2 = [[NSSortDescriptor alloc] initWithKey:@"endMonth" ascending:YES];
NSSortDescriptor *descriptor3 = [[NSSortDescriptor alloc] initWithKey:@"periodLength" ascending:YES];
NSArray *sortDescriptors = @[descriptor1, descriptor2, descriptor3];
[fetchRequest setSortDescriptors:sortDescriptors];