Skip to content

Instantly share code, notes, and snippets.

View miketihonchik's full-sized avatar

mike tihonchik miketihonchik

View GitHub Profile
@miketihonchik
miketihonchik / iOS_6_status_bar
Created September 24, 2013 18:25
Create iOS6 like status bar in iOS7 application (I do this in didFinishLaunchingWithOptions method in AppDelegate)
if(IS_IOS_7) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0, 20, self.window.frame.size.width,self.window.frame.size.height-20);
self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
}
return YES;
@miketihonchik
miketihonchik / DrawTextOnImage
Created August 29, 2013 16:39
draw text over any image (pass additional parameters, so that text is not pixelated)
- (UIImage *)drawTextOnImage:(NSString *)text :(UIImage *)img {
UIGraphicsBeginImageContextWithOptions(img.size, NO, [UIScreen mainScreen].scale);
CGRect imageBoundaries = CGRectMake(0,0, img.size.width, img.size.height);
[img drawInRect:imageBoundaries];
imageBoundaries.origin.y = (imageBoundaries.size.height - 14) / 2 - 4;
imageBoundaries = CGRectIntegral(imageBoundaries);
imageBoundaries.size.height = 14;
[[UIColor grayColor] set];
@miketihonchik
miketihonchik / UseAssetsLibrary
Created August 14, 2013 13:52
sample functions calls to get the images from the iPhone image library
#import <AssetsLibrary/AssetsLibrary.h>
- (void)viewDidLoad
{
[super viewDidLoad];
void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if( result != nil)
{
@miketihonchik
miketihonchik / DrawTextOnImage.m
Last active December 20, 2015 08:19
Create text overlay on the UIImage
- (UIImage *)drawTextOnImage:(NSString *)text :(UIImage *)img {
UIGraphicsBeginImageContext(img.size);
CGRect imageBoundaries = CGRectMake(0,0, img.size.width, img.size.height);
[img drawInRect:imageBoundaries];
[[UIColor grayColor] set];
[text drawInRect:imageBoundaries withFont:[UIFont boldSystemFontOfSize:15] lineBreakMode:NSLineBreakByTruncatingTail alignment:NSTextAlignmentCenter];
UIImage *theImage=UIGraphicsGetImageFromCurrentImageContext();
@miketihonchik
miketihonchik / BypassCertificateValidation.java
Created July 12, 2013 18:48
this is fix for "famous" javax.net.ssl.SSLHandshakeException: unable to find valid certification path to requested target it's OK to use this for testing, but not production
/*
** this is fix for "famous" javax.net.ssl.SSLHandshakeException:
** unable to find valid certification path to requested target
** it's OK to use this for testing, but not production
*/
public static void disableCertificateValidation() {
// Create new Trust Manager that will not validate any of the certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {