Selective layer borders

March 4, 2012

I always though that the most annoying problems are the ones that should have been trivial. Those pesky problems that happen all the time, and for some reason apple didn’t take the time to fix them.

One such problem is the fact that there is no easy way to draw “selective” borders – i.e draw borders only on the left and top side of the view.

This problem keeps popping up for me, the last time was when I was trying to draw a grid view with custom cells. I wanted the cells to have a 1px border, but since all cell had both top and bottom borders, the borders seemed to be 2px wide.

This time I decided to solve this problem the right way and make a simple drop-in class that provides flexible border abilities – something that I could use like this:


myView.borderDirection = AUIFlexibleBordersDirectionRight | AUIFlexibleBordersDirectionTop;

Read the rest of this entry »


Adding custom code snippets extensions

November 1, 2011

One of the most useful feature of xcode 4 was the built in code snippets library. It allows you to use pre made pieces of code instead of writing them over and over.

You can use those code snippets either by dragging them from the Code Snippet Library section, or by simply typing a completion shortcut.

xcode comes with a variaty of useful code snippets which you are more than welcomed to browse, but today I will show you how to add your own custom code snippets.

Read the rest of this entry »


Instantiating custom views from nib

October 18, 2011

Hi again everyone!

Subclassing UIView to create your own custom class is one of the most frequent tasks an iOS developer has to do.

And for me at least, every time that i created my own custom view, i was torn apart by what is the correct and more convenient way to design my view – from code or from interface builder. I always thought that there was no “right answer”, and that this decision depends on the scenario.
I was wrong. Using interface builder is better. Let’s see why.
Read the rest of this entry »


Animatable text color of UILabel

October 4, 2011

Every time I talk with an android developer about the strong and weak points of iOS development, I always have the CoreAnimation ace up my sleeve. Core animation is great. Not only that it’s so powerful and efficient, it’s also one of the most elegant frameworks I got the chance to work with. In 95% of the cases you can just write

 [UIView animateWithBlock:..] 

and pass a block with the final values of each property we want to animate.

Being the lazy developer that I am, the UIView animation block is a dream come true. This is why I get so annoyed when I encounter a non animatable property, like the text color property of UILabel. That’s right – UILabel, our main component for showing text on the screen, can’t animate all of its text related properties, like textColor, text, font, etc.

If we want to animate textColor, we have two simple but ugly options, and one complicated but delicious solution. Lets talk about the uglies first.
Read the rest of this entry »