RecentChanges 2014-12-21 XML TXT

Latest weblog entries

2014-12-15 Shadows and rounded corners

The app I'm currently working on, requires a textfield with shadow and rounded corners. That doesn't work on a UITextField; you'll have to make it transparent, then add it to a plain UIView and style that.

I got curious and tried to add shadows and rounded corners to a number of elements in UIKit. This is the code:

        import UIKit
	class ViewController: UIViewController {
		@IBOutlet weak var contentView: UIView!
		@IBOutlet weak var button: UIButton!
		@IBOutlet weak var textfield: UITextField!
		@IBOutlet weak var textView: UITextView!
		@IBOutlet weak var datePicker: UIDatePicker!
		@IBOutlet weak var toolbar: UIToolbar!
		@IBOutlet weak var imageView: UIImageView!
		override func viewDidLoad() {
		func addShadowAndCornerRadius(view: UIView) {
			let radius:CGFloat = 20.0
			view.layer.cornerRadius = radius
			view.layer.shadowColor = UIColor.darkGrayColor().CGColor
			view.layer.shadowPath = UIBezierPath(roundedRect: view.bounds,
			    cornerRadius: radius).CGPath
			view.layer.shadowOffset = CGSize(width: 0, height: 0)
			view.layer.shadowOpacity = 1.0
			view.layer.masksToBounds = true
			view.clipsToBounds = false

Below is the result in the simulator. Note that the light-blue empty element is a plain UIView.

shadow and rounded corners uikit.png

As you can see, adding shadow and rounded corners doesn't work on UIImageView, UITextField and UIToolbar. It does work on a plain UIView, UIButton, UITextView and UIDatePicker.

2014-11-18 Swift optionals

Recently I dived into Swift and in order to grok optionals, first read this article on Medium: Swift Optionals and then this comment on Stack Overflow.

2014-11-06 From mov to animated gif

On OS X, the standard QuickTime Player application can record (a part of) your screen, or record the screen of an iOS device over the lightning cable.

You then get a .mov file. You can convert this into an animated gif of slightly smaller size with ffmpeg. You'll need to install homebrew first, and using the brew command, install ffmpeg as follows:

 $ brew install ffmpeg

Then open a terminal and change to the desktop folder or wherever you saved the movie file, and issue the following command:

 $ ffmpeg -i -r 15 demo.gif

Drag the resulting demo.gif to Safari to view it. The quality is pretty bad, but hey, animated gifs are all the rage nowadays.

2014-10-18 Remapping your keyboard in OS X Yosemite

If you want to remap your notebook's or external keyboard, there's an excellent and free choice available: Karabiner from the friendly Takayama Fumihiko.

Upon upgrading OS X yesterday, I found it worked straight away in Yosemite as well.

Besides remapping the obvious keys, if you would like to remap that useless Caps Lock key on OS X, get Seil.


On iOS 8, user permission is required for scheduling local notifications (of class UILocalNotification). Here's an Objective-C example.

To check whether you have permission:

  - (BOOL)appHasPermissionForLocalNotifications
      UIUserNotificationSettings *settings = [[UIApplication sharedApplication] currentUserNotificationSettings];
      if(settings.types & (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)) {
          NSLog(@"Permission present: 0x%ulX", settings.types);
          return YES;
      } else {
          NSLog(@"Permission not present: 0x%ulX", settings.types);
          return NO;

To request permission:

  [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];


Weblog Archive

Weblog entries 2014

Weblog entries 2013

Weblog entries 2012

Weblog entries 2011

Weblog entries 2010

Weblog entries 2009

Weblog entries 2008

Weblog entries 2007

Weblog entries 2006

Weblog entries 2005

Weblog entries 2004

All weblog entries


Articles, chronologically (latest first). This is pretty old stuff.


Not yet finished. Maybe will never be finished. Maybe they'll get deleted. Who knows?


System administration: