This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // GCD using "instancetype" as return type | |
| + (instancetype)shared | |
| { | |
| static id shared; | |
| static dispatch_once_t token; | |
| dispatch_once(&token, ^{ | |
| shared = [[self alloc] init]; | |
| }); | |
| return shared; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/WindowAndScreenGuide/WindowScreenRolesinApp/WindowScreenRolesinApp.html#//apple_ref/doc/uid/TP40012555-CH4-SW1 | |
| // Important: When you create a window programmatically, always set the size of the window to the full bounds of the screen object. | |
| // In particular, don’t reduce the size of the window to accommodate the status bar or any other items. | |
| // If you are using view controllers, the view controller should handle the sizing of your views automatically. | |
| - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
| UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
| myViewController = [[MyViewController alloc] init]; | |
| window.rootViewController = myViewController; | |
| [window makeKeyAndVisible]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [button setTranslatesAutoresizingMaskIntoConstraints: NO]; | |
| id topGuide = myViewController.topLayoutGuide; | |
| NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings (button, topGuide); | |
| [myViewController.view addConstraints: | |
| [NSLayoutConstraint constraintsWithVisualFormat: @"V: [topGuide]-20-[button]" | |
| options: 0 | |
| metrics: nil | |
| views: viewsDictionary] | |
| ]; | |
| self.view.layoutSubviews; // You must call this method here or the system raises an exception |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static int getTextHeight(String text, int maxWidth, float textSize, Typeface typeface) { | |
| TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); | |
| paint.setTextSize(textSize); | |
| paint.setTypeface(typeface); | |
| int lineCount = 0; | |
| int index = 0; | |
| int length = text.length(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //viewDidload | |
| if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { | |
| // iOS 7 | |
| [self prefersStatusBarHidden]; | |
| [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; | |
| } else { | |
| // iOS 6 | |
| [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n=0 | |
| for file in *.jpg; do | |
| file_name="$n.jpg" | |
| n=$(( $n+1 )) | |
| mv $file $file_name | |
| done |