Skip to content

Instantly share code, notes, and snippets.

@jordiboehme
jordiboehme / gist:3168819
Created July 24, 2012 08:25
iOS Pixel-to-Points conversion
+(CGFloat)pixelToPoints:(CGFloat)px {
CGFloat pointsPerInch = 72.0; // see: http://en.wikipedia.org/wiki/Point%5Fsize#Current%5FDTP%5Fpoint%5Fsystem
CGFloat scale = 1; // We dont't use [[UIScreen mainScreen] scale] as we don't want the native pixel, we want pixels for UIFont - it does the retina scaling for us
float pixelPerInch; // aka dpi
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
pixelPerInch = 132 * scale;
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
pixelPerInch = 163 * scale;
} else {
pixelPerInch = 160 * scale;
@jordiboehme
jordiboehme / FontRegistry.m
Created July 26, 2012 10:04
UIFont from a CSS definition
//
// FontRegistry.h
// Tabris
//
// Created by Jordi Böhme López on 25.07.12.
// Copyright (c) 2012 EclipseSource.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
@jordiboehme
jordiboehme / gist:3526472
Created August 30, 2012 11:13
Handling Camera and Album UIImages on iOS
//
// ImageHelper.h
// Tabris
//
// Created by Jordi Böhme López on 22.08.12.
// Copyright (c) 2012 EclipseSource. All rights reserved.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
@jordiboehme
jordiboehme / layout.js
Created February 18, 2015 14:19
tabris.js layout example
var page = tabris.create("Page", {
title: "Hello Layout!",
topLevel: true
});
tabris.create("Button", {
id: "btn1",
text: "Button 1",
layoutData: {top: 10, left: 10, right: 10}
}).appendTo(page);