Skip to content

Instantly share code, notes, and snippets.

View vitoziv's full-sized avatar
🐙
Writing bugs

Vito vitoziv

🐙
Writing bugs
View GitHub Profile
@vitoziv
vitoziv / UIImage+VI_Resize.m
Created July 4, 2014 06:22
Resize Image With low memory
+ (UIImage *)resizeImage:(UIImage *)image scaledToFitSize:(CGFloat)max
{
NSData *imageData = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0)];
CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL);
if (!imageSource)
return nil;
CFDictionaryRef options = (__bridge CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
(id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailWithTransform,
(id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailFromImageIfAbsent,
@vitoziv
vitoziv / search_archs
Created March 20, 2014 06:16
find ARCHS in build setting
xcodebuild -scheme MyScheme -showBuildSettings | grep ARCHS
@vitoziv
vitoziv / BCP-47.txt
Created February 20, 2014 07:08
BCP-47 code for AVSpeechSynthesisVoice
Arabic (Saudi Arabia) - ar-SA
Chinese (China) - zh-CN
Chinese (Hong Kong SAR China) - zh-HK
Chinese (Taiwan) - zh-TW
Czech (Czech Republic) - cs-CZ
Danish (Denmark) - da-DK
Dutch (Belgium) - nl-BE
Dutch (Netherlands) - nl-NL
English (Australia) - en-AU
English (Ireland) - en-IE
@vitoziv
vitoziv / DeclareABlockInObjective-C.md
Last active January 1, 2016 15:59
How Do I Declare A Block in Objective-C?

How Do I Declare A Block in Objective-C?

As a local variable:

returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};

As a property:

@property (nonatomic, copy) returnType (^blockName)(parameterTypes);
@vitoziv
vitoziv / rotationAnimation.m
Created December 16, 2013 08:11
360℃旋转动画
- (void)runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat;
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = repeat;
[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
@vitoziv
vitoziv / NoShadowTableView.m
Created December 11, 2013 07:36
NoShadowTableView - Removing reorder cell shadows from a UITableView
#import "NoShadowTableView.h"
@interface NoShadowTableView ()
{
// iOS7
__weak UIView* wrapperView;
}
@end
@vitoziv
vitoziv / IS IOS7 Version
Created December 11, 2013 06:47
IS IOS7 Version
NSUInteger DeviceSystemMajorVersion();
NSUInteger DeviceSystemMajorVersion()
{
static NSUInteger _deviceSystemMajorVersion = -1;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];
});
return _deviceSystemMajorVersion;
}
Pod::Spec.new do |s|
s.name = 'moves-ios-sdk'
s.version = '0.1.0'
s.platform = :ios,'6.0'
s.license = 'https://github.com/vitoziv/moves-ios-sdk/blob/master/LICENSE'
s.summary = 'Moves app iOS SDK '
s.homepage = 'https://github.com/vitoziv/moves-ios-sdk'
s.author = {
'Vito Zhang' => '[email protected]'
}
@vitoziv
vitoziv / convertTimeFromSeconds.m
Last active December 28, 2015 09:48
convertTimeFromSeconds.m
- (NSString *)convertTimeFromSeconds:(NSString *)seconds
{
// Return variable.
NSString *result = @"";
// Int variables for calculation.
int secs = [seconds intValue];
// Convert the seconds to hours, minutes and seconds.
int tempHour = secs / 3600;
# OS X
.DS_Store
# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3