Skip to content

Instantly share code, notes, and snippets.

View blitzvb's full-sized avatar

Vincent Bellet blitzvb

  • tapstic
  • san Jose
View GitHub Profile
@blitzvb
blitzvb / gist:87c8238f23c6de07e4d5
Created January 3, 2015 23:21
load image in background thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void) {
NSData *data0 = [NSData dataWithContentsOfURL:someURL];
UIImage *image = [UIImage imageWithData:data0];
dispatch_sync(dispatch_get_main_queue(), ^(void) {
UIImageView* imageView = (UIImageView*)[cell viewWithTag:100];
imageView.image = image;
});
});
@blitzvb
blitzvb / gist:7696435
Created November 28, 2013 18:34
Swizzling Method in #xamarin
[DllImport ("/usr/lib/libobjc.dylib")]
extern static IntPtr class_getInstanceMethod (IntPtr classHandle, IntPtr Selector);
[DllImport ("/usr/lib/libobjc.dylib")]
extern static Func<IntPtr,IntPtr,IntPtr> method_getImplementation (IntPtr method);
[DllImport ("/usr/lib/libobjc.dylib")]
extern static IntPtr imp_implementationWithBlock (ref BlockLiteral block);
[DllImport ("/usr/lib/libobjc.dylib")]
extern static void method_setImplementation (IntPtr method, IntPtr imp);
static Func<IntPtr,IntPtr,IntPtr> original_impl;
@blitzvb
blitzvb / gist:7582002
Last active April 17, 2021 02:01
here how to create a UIImage from a font. #xamarin #ios
public static UIImage ImageWithFont(string fontName,float fontSize,SizeF imageSize,UIColor color,string text)
{
if (fontName != null && text != null && color != null) {
UIGraphics.BeginImageContextWithOptions (imageSize, false, 0.0f);
NSAttributedString attrString = new NSAttributedString (text, new UIStringAttributes () {
Font = UIFont.FromName (fontName,fontSize),
ForegroundColor = color
});
@blitzvb
blitzvb / gist:7581976
Last active December 28, 2015 23:49
Here how to retrieve the status bar UIView. #xamarin #ios
public static UIView GetStatusBar()
{
return (UIView) UIApplication.SharedApplication.ValueForKey (new NSString("_statusBarWindow"));
}
@blitzvb
blitzvb / gist:7581854
Last active December 28, 2015 23:49
Retrieve the hardware model of the device. #xamarin #ios Last updated : 11/05/13
public enum HardwareVersion
{
iPhone2G,
iPhone3G,
iPhone3Gs,
iPhone4, // retina
iPhone4s,
iPhone5,
iPhone5c,
iPhone5s,
@blitzvb
blitzvb / gist:5191480
Created March 18, 2013 22:37
Easy AutoLayout help from Frank
My View Controller :
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Async.iOS;
namespace FrankAutoLayout