Skip to content

Instantly share code, notes, and snippets.

@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
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;
//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) {
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) {
@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;
@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 / 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;
namespace FSHelloSceneKit
open System
open MonoTouch.UIKit
open MonoTouch.Foundation
open MonoTouch.SceneKit
type FSHelloSceneKitViewController () =
inherit UIViewController()
@mikebluestein
mikebluestein / EffectsController.cs
Created July 8, 2014 22:19
iOS 8 Visual Effects using Xamarin
using System;
using System.Drawing;
using MonoTouch.UIKit;
namespace ViewEffectsDemo
{
public class EffectsController : UIViewController
{
UIImageView imageView;
UIScrollView scrollView;
rollin in C.T. ...VW in gear 3
pickin up the milk, the produce, and some tea
dropin crazy rhymes, while I'm running out of time
got my wife some flowers, forgot the movie, but got Amazon Prime
hey ho
but got Amazon Prime
hey ho
but got Amazon Prime