Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mikebluestein
mikebluestein / HelloSceneKitController.cs
Last active November 18, 2022 20:57
A simple iOS 8 Scene Kit example using C# and Xamarin
using System;
using MonoTouch.UIKit;
using MonoTouch.SceneKit;
using MonoTouch.Foundation;
namespace HelloSceneKit
{
public class HelloSceneKitController : UIViewController
{
SCNView sceneView;
@mikebluestein
mikebluestein / gist:8532580
Created January 21, 2014 01:15
Display a QR Code in Xamarin.iOS using Core Image
var qrCode = new CIQRCodeGenerator {
Message = NSData.FromString (someText),
CorrectionLevel = "Q"
}.OutputImage;
UIGraphics.BeginImageContext (new SizeF (qrCode.Extent.Width * 8, qrCode.Extent.Height * 8));
var cgCtx = UIGraphics.GetCurrentContext ();
var ciCtx = CIContext.FromOptions (null);
cgCtx.InterpolationQuality = CGInterpolationQuality.None;
cgCtx.DrawImage (cgCtx.GetClipBoundingBox (), ciCtx.CreateCGImage (qrCode, qrCode.Extent));
@mikebluestein
mikebluestein / gist:8061285
Created December 20, 2013 20:46
NSAttributedString with HTML
NSError error = null;
var htmlString = new NSAttributedString (NSUrl.FromFilename (
"Test.html"),
new NSAttributedStringDocumentAttributes{ DocumentType = NSDocumentType.HTML },
ref error);
textView.AttributedText = htmlString;
NSError err;
ab = ABAddressBook.Create (out err);
if (err == null) {
ab.RequestAccess ((allowed, err1) => {
if (allowed) {
var people = ab.GetPeople ();
foreach (ABPerson person in people) {
//does the actual coloring
void DrawPoints (CGContext dctx)
{
dctx.BeginPath ();
dctx.MoveTo (Points.First().X, Points.First().Y);
dctx.SetLineWidth(swatchSlider.Value);
dctx.SetBlendMode (CGBlendMode.Normal);
foreach (var crayon in Crayons) {
public NSArray ToNSArray (int[] array)
{
NSArray nsArray = null;
var objects = Array.ConvertAll (array, i => (object)i);
if (objects != null) {
nsArray = NSArray.FromObjects (objects);
}
return nsArray;
@mikebluestein
mikebluestein / gist:2079186
Created March 18, 2012 18:18
Add a TXTRecord using Bonjour and MonoTouch
NetDelegate _netDel;
NSNetService _ns;
void InitNetService ()
{
_ns = new NSNetService ("", "_testservice._tcp", UIDevice.CurrentDevice.Name, 9999);
_netDel = new NetDelegate ();
_ns.Delegate = _netDel;
// add TXTRecordData