Skip to content

Instantly share code, notes, and snippets.

@fhefh2015
fhefh2015 / new_gist_file
Created May 24, 2016 03:09
CAAnimateGroup组合动画
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
CABasicAnimation *baseAnimate1 = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
baseAnimate1.toValue = @(0.1);
baseAnimate1.duration = 0.5;
CABasicAnimation *baseAnimate2 = [CABasicAnimation animationWithKeyPath:@"position"];
baseAnimate2.toValue = [NSValue valueWithCGPoint:CGPointMake(0, 0)];
baseAnimate2.duration = 0.5;
@fhefh2015
fhefh2015 / new_gist_file
Created August 1, 2016 14:57
正确的绘制Grid线条 1px细线
//
// SvGridView.h
// SvSinglePixel
//
// Created by xiaoyong.cxy on 6/23/15.
// Copyright (c) 2015 smileEvday. All rights reserved.
//
#import <UIKit/UIKit.h>
@fhefh2015
fhefh2015 / UITableView+reloadDataAnimated.m
Created August 6, 2016 10:48 — forked from tony0x59/UITableView+reloadDataAnimated.m
tableview重载数据时的淡入淡出动画过渡效果
#import "UITableView+reloadDataAnimated.h"
@implementation UITableView (reloadDataAnimated)
- (void)reloadDataWithAnimated:(BOOL)animated
{
[self reloadData];
if (animated) {
CATransition *animation = [CATransition animation];
@fhefh2015
fhefh2015 / label.m
Last active June 26, 2020 03:35
UILabel两端对齐
- (NSAttributedString *)textAligenJustifiedWith:(NSString *)text lineSpace:(CGFloat)lineSpace {
NSMutableAttributedString *mutableAttributedString = [[NSMutableAttributedString alloc] initWithString:text];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = NSTextAlignmentJustified;
paragraphStyle.paragraphSpacing = 11.0;
paragraphStyle.paragraphSpacingBefore = 10.0;
paragraphStyle.firstLineHeadIndent = 0.0;
version=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $PRODUCT_SETTINGS_PATH`
version=`expr $version + 1`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $version" $PRODUCT_SETTINGS_PATH
#/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $version" $PRODUCT_SETTINGS_PATH 这行代码会让version也自增,一般不需要
@fhefh2015
fhefh2015 / new_gist_file
Created August 9, 2016 08:43
iOS获取设备IP地址
#import <ifaddrs.h>
#import <arpa/inet.h>
#import <net/if.h>
#define IOS_CELLULAR @"pdp_ip0"
#define IOS_WIFI @"en0"
#define IOS_VPN @"utun0"
#define IP_ADDR_IPv4 @"ipv4"
#define IP_ADDR_IPv6 @"ipv6"
@fhefh2015
fhefh2015 / new_gist_file
Created August 9, 2016 08:53
iOS 银行卡合法性校验
//剔除卡号里的非法字符
-(NSString *)getDigitsOnly:(NSString*)s
{
NSString *digitsOnly = @"";
char c;
for (int i = 0; i < s.length; i++)
{
c = [s characterAtIndex:i];
if (isdigit(c))
{
@fhefh2015
fhefh2015 / new_gist_file
Created August 15, 2016 09:04
AFNetworking 3.0 队列同步
//方法一
NSString *urlString1 = @"...";
NSString *urlString2 = @"...";
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
queue.name = @"AFHTTPSessionManager queue";
NSOperation *completionOperation = [NSBlockOperation blockOperationWithBlock:^{
@fhefh2015
fhefh2015 / new_gist_file.js
Created August 25, 2016 02:35
获取URL搜索字符串参数
function urlArags() {
var args = {};
var query = window.location.search.substring(1);
var pairs = query.split("&");
for (var i = 0, len = pairs.length; i < len; i++) {
var pos = pairs[i].indexOf('=');
if (pos == -1) {
continue;
@fhefh2015
fhefh2015 / new_gist_file.php
Created August 29, 2016 03:10
PHP 随机用户名账号的生成
private function genUserNumber()
{
$chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$username = "";
for ( $i = 0; $i < 6; $i++ )
{
$username .= $chars[mt_rand(0, strlen($chars))];
}
return strtoupper(base_convert(time() - 1420070400, 10, 36)).$username;
}