background preloader

Snippets

Facebook Twitter

iPhone SDK Examples. UINavigationBar with solid color or image background. How about a nice navigation bar without default iPhone gradient or with a beautiful background image? Lets do it! The thing we’re going to do in both sub-solutions is to override UINavigationBar drawRect function with a help of category. As you may or may not know categories helps us to add additional functionality to an existing classes even if we can’t access their source directly. For more information read Extending Classes in Objective-C With Categories. UINavigationBar category First, as I mentioned before, lets override drawRect method with our own. At this point if you run your application (just don’t forget to actually have UINavigationController with visible navigation bar in it) navigation bar will look like.. em.. black rectangle.

Solid color background So I’ve heard you hate gradients? And just look at our results! But aren’t we forgetting something? Background image Using image for UINavigationBar background is even more simple! Iphone - Custom UINavigationBar Background. Shuffling an NSArray. Apr 23, 2009 For a project I am working on I needed to shuffle the contents of an NSArray without harming the items themselves.

NSArray is a convenient container because it does not care about what you put inside. This is because you don’t (put objects into arrays), you only pretend. You cannot add an object itself into an array but instead you always insert pointers to class instances. NSArray and its bigger cousin NSMutableArray will keep track of the pointers and memory management of the items so you don’t have to. The header NSArray+Helpers.h: The implementation NSArray+Helpers.m: The implemented method works by adding the object references to a temporary NSMutableArray at random positions.

How to use it: You might have noticed previously that I have grown very fond of Class Categories. Like this: Like Loading... Categories: Recipes. What Color is My Pixel? Image based color picker on iPhone. My Postcards app has a design screen where you can change colors of things, so I needed a color picker.

What Color is My Pixel? Image based color picker on iPhone

A very easy way to make a color picker on just about any platform is to make some kind of color pallet image file, display it for the user to click on, and do a call like: getPixelColorAtScreenLocation(x,y) This was available back in 1983 on my ZX-Spectrum, but alas Cocoa Touch doesn't have it. (If I missed something I hope a reader will set me straight.) What are some alternatives then? Ditch the color pallet and use sliders to mix colors. Not very user friendly for the everyday user.Manually build a lookup table for position to color. Googling around turned up a way to make the last technique work, which is good because we're using existing APIs, and it will work for any image: I've wrapped this up in ColorPickerImageView, a subclass of UIImageView.

Images

Simulate mem warnings. RegexKitLite. Lightweight Objective-C Regular Expressions for Mac OS X using the ICU Library 2010-04-18, v4.0 Introduction to RegexKitLite This document introduces RegexKitLite for Mac OS X.

RegexKitLite

RegexKitLite enables easy access to regular expressions by providing a number of additions to the standard Foundation NSString class. RegexKitLite acts as a bridge between the NSString class and the regular expression engine in the International Components for Unicode, or ICU, dynamic shared library that is shipped with Mac OS X. Highlights Who Should Read This Document This document is intended for readers who would like to be able to use regular expressions in their Objective-C applications, whether those applications are for the Mac OS X desktop, or for the iPhone. This document, and RegexKitLite, is also intended for anyone who has the need to search and manipulate NSString objects. Regular expressions are a powerful way to search, match and extract, and manipulate strings. Organization of This Document Important: