Skip to content

Instantly share code, notes, and snippets.

View MaximAlien's full-sized avatar

Maxim Makhun MaximAlien

View GitHub Profile
@MaximAlien
MaximAlien / iOSUICollectionViewStub
Last active December 24, 2015 12:12
[iOS] Stub used for quick UICollectionView integration
// ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UICollectionViewDelegate, UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@end
@MaximAlien
MaximAlien / iOSUITableViewStub
Last active June 1, 2017 16:53
[iOS] Stub used for quick UITableView integration
// ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@end
@MaximAlien
MaximAlien / iOSDebugCheck
Created November 16, 2015 08:20
[iOS] Check for Debug/Release
#if DEBUG
println("debug")
#else
println("Not debug")
#endif
@MaximAlien
MaximAlien / AnimView
Created November 4, 2015 15:27
[iOS] [CAAnimation] Simple animation of the view
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 50, 50, 50)];
[view setBackgroundColor:[UIColor blackColor]];
[self.view addSubview:view];
CABasicAnimation *animation = [CABasicAnimation animation];
animation.keyPath = @"position.x";
animation.fromValue = @0;
animation.toValue = @(self.view.frame.size.width);
animation.duration = 1;
animation.fillMode = kCAFillModeForwards;
@MaximAlien
MaximAlien / AssignIntJNI
Last active October 21, 2015 11:22
[Android] [JNI] Assign value of the int array through JNI
int[] intVal = new int[1];
JNIEXPORT jboolean JNICALL Java_com_test_example_ChIntVal_change_int(JNIEnv* env, jobject cls, jintArray intValArray)
{
int testVal = -1;
jint *exTypeVal = env->GetIntArrayElements(intValArray, 0);
exTypeVal[0] = testVal;
env->ReleaseIntArrayElements(intValArray, exTypeVal, 0);
@MaximAlien
MaximAlien / DeviceTypeDetection
Created September 15, 2015 15:37
[iOS] Code which detects what type of device is used: Phone or Tablet.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
NSLog(@"iPad");
}
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
NSLog(@"iPhone");
}
@MaximAlien
MaximAlien / LaunchImageSize
Last active September 15, 2015 12:46
[iOS] Launch image sizes
Width x Height
iPhone 4:
320 x 480 - portrait
480 x 320 - landscape
iPhone 4s (@2x):
640 x 960 - portrait
960 x 640 - landscape
@MaximAlien
MaximAlien / GetCountriesList
Created May 22, 2015 15:48
[iOS] GetCountriesList
NSMutableArray *countries = [[NSMutableArray alloc] init];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier: @"en_US"];
NSArray *countryArray = [NSLocale ISOCountryCodes];
for (NSString *countryCode in countryArray)
{
NSString *displayName = [locale displayNameForKey:NSLocaleCountryCode value:countryCode];
[countries addObject:displayName];
}
@MaximAlien
MaximAlien / FontName
Created May 22, 2015 13:04
[iOS] Get all font names
for (NSString* family in [UIFont familyNames])
{
NSLog(@"%@", family);
for (NSString* name in [UIFont fontNamesForFamilyName:family])
{
NSLog(@"- %@", name);
}
}
@MaximAlien
MaximAlien / TabBarImageSizes
Last active August 29, 2015 14:21
[iOS] [UI] Tab bar image sizes
iPhone 6 Plus (@3x) - 75 x 75
iPhone 6 and iPhone 5 (@2x) - 50 x 50
iPhone 4s (@2x) - 50 x 50
iPad and iPad mini (@2x) - 50 x 50
iPad 2 and iPad mini (@1x) - 25 x 25