Friday, November 28, 2014

Extending NSDate to add a Start of Day Method

New NSDate objects are created by default with the current time and date. This is useful for most things. However sometimes you may only want the date. One way to achieve this is to modify the NSDate object's time elements using  the NSCalendar and NSDateComponent classes to set the time to the first second of the day. This article will describe how to do this by creating a Swift extension to the NSDate class that will add a 'start of day' method.

Wednesday, October 29, 2014

How to create a Custom Table View Cell in Interface Builder

Introduction

Custom table view cells are a powerful way to extend the functionality of table views. In this article I am going to demonstrate how to create a custom table view cell in Interface Builder using as little actual code as possible.

Wednesday, October 15, 2014

How To Make an iOS Label Grow Automatically

Introduction

iOS label controls can be configured to autoshrink. This automatically reduces the size of the font used to draw them to fit the text assigned to them into their frame. Their frame is the bounding rectangle they are drawn into. The size of the frame can be set in Interface Builder using constraints.

In this article I am going to describe my attempt to make an Autogrow label. My goal is to create a label that automatically increases its font size so that the text assigned to it fills its frame.
The method I am going to use is to set the label's font size to the maximum allowed by Interface Builder and enable autoshrink. My hope is that the font will then be shrunk until the text just fits in the frame.
This is a three step process:

1. Use constraints to set the size of the label to be relative to the size of the view.
2. Set the label's autoshrink attributes.
3. Increase the label's font size.

Thursday, October 9, 2014

How to Hide the Navigation Bar on an iOS View


Introduction

Many iOS apps use a navigation controller as the main way to link different views together. 
By default the navigation controller inserts a navigation bar at the top of each view. This is usually desirable as it provides a visual indication of the structure of your app. However there are some circumstances where it is desirable to hide the navigation bar for some views within your app. For example if a view's purpose is to display a picture or some other graphic you may want to use the whole of the display.

In this article I am going to discuss how to do this using iOS8 and Swift.