Make your custom view’s properties available in Storyboards

Let’s say you want to configure some parts of your view rendering directly in your storyboards.  Fortunately you can by using @IBInspectable.


Result in Xcode

Screen Shot 2016-06-14 at 3.34.17 PM


Screen Shot 2016-06-14 at 3.34.13 PM

Here is the project ( Xcode 8, Swift 3) if you want to try it : IBInspectableDemo

That’s it folks, have a good day !



How to outline your UILabel & UIButton

I recently had a problem with a yellow label on a dynamic background that can sometimes also be yellow.  The two common solutions are

  • Add a shadow.
  • Outline your text.

NSAttributedString offers everything you need to do it.

Filled & Outlined

Screen Shot 2016-06-09 at 1.32.07 PM


Filled ?

Note that the stroke width attribute is a negative value.

This is to tell the drawing engine it is a “Stroke & Fill” operation.  Otherwise it’ll just ignore the “NSForegroundColorAttributeName” and leave the text transparent like this :

Screen Shot 2016-06-09 at 1.44.33 PM

Link to the playground : MABDev.OutlinedText.playground

Documentation :



The swift class extension you’ll want to include in all your projects

Here is one of my favorite extension I created for Array. Very useful shortcut when you use abstraction ( as you should ) and you want to create an array from another one.


Instantiate an Array of type A with an another array of type ( or protocol ) B and fills it with elements from B that can be cast to A.



Screen Shot 2016-06-08 at 2.57.33 PM

You could always use .filter but it would take way more lines.  I often use it to get a specific subview in my view hierarchy.  Here’s the link to the playground file.


That’s it for today folks !  See you soon. MAB.


UIImage, prepareForReuse and multiple reload data

So you are working on a UICollectionView and you have to call “reloadData()” a few times in a row because you have data coming in. I know it would be better to insert items or at least reload the section but sometimes for good or bad reasons, like custom layout manager and iOS 9, it’s not always possible. And it’s not the point here anyway.  The point is I recently had a problem with my UIImageView flashing like crazy overtime I call “reloadData()” .  I found out in your “prepareForReuse()” implementation, rather than setting you imageView.image = nil you’re better off doing imageView.hidden = true and unhide it later when you need to set it again in “cellForItemAtIndexPath”.


Not much but I thought it could interest some of you guys. Cheers !

Edit: It might not be the best solution after all. It behave poorly in bad / slow network conditions.