Swift Snippet : Map Bool values with Generics in Swift

My problem

It often occurs while writing code that you need to assign a value of a certain type, based on the value of Boolean. To do this there are multiple ways, but the 2 most known are

1. The let’s-write-a-lot-of-code approach

let isAWildBoolean = true

// Set the value of `offSet` to a value based on the Boolean
let offSet:Int

if isAWildBoolean {
    
    offSet = 10
    
} else {
    
    offSet = 20
    
}

I don’t like the first approach, because it creates a bloated codebase. A better way is to use the ternary operator (also known as the inline-if).

2. The one-line-star-developer (ternary operator) approach

You specify the Boolean you want to evaluate, add a question mark, followed by the value if the Boolean is true, followed by a colon, followed by the value if the Boolean is false.

Continue reading Swift Snippet : Map Bool values with Generics in Swift

TNInfoBubble – Prisma app info bubble component

I was using the Prisma app (like half of the world probably) and noticed the info bubble when you swipe with your fingers to adjust the strength of the effect.

This is my implementation (written in Swift) of this component, which comes with the Prisma look out of the box.

Continue reading TNInfoBubble – Prisma app info bubble component

A better way to integrate Unity3D within a native iOS app

Update: I’ve created a new tutorial for Xcode 7 & Unity 5.

Last year I published a blog post about how to integrate Unity3D within a native iOS application.

Last week I found a better way to integrate Unity3D within a native iOS app, which also eliminates some issues with my previous version.  Because it’s quite a long explanation to do and I noticed in my previous blog post that not everything was crystal clear, I’ve made a video tutorial how you can achieve this.

Continue reading A better way to integrate Unity3D within a native iOS app

TNSwiftyCheckboxGroup, create checkbox groups in Swift

TNCheckboxGroup

Last year I published TNCheckboxGroup for Objective-C, but I had a few comments it didn’t work when using with Swift. So I just published a Swift version on Github. This versions leverages UICollectionView to handle big sets of checkboxes. TNSwiftyCheckboxGroup, create checkbox groups in Swift.

Continue reading TNSwiftyCheckboxGroup, create checkbox groups in Swift

TNImageSliderViewController – an image slider gallery for Swift

The problem

Too many times a client has asked to add a sliding image gallery to an iOS app, so I wrapped it up in a little component. You can download it from GitHub.

Introducing an image slider gallery for Swift

I took some time to write this component, so it is easy to manage image slider galleries.  First I looked around on the web, but there was nothing that really fitted my needs, so the best thing to do in such a case is write it yourself :-).

Prerequisites

  • Xcode
  • iOS8+

Features

  • Horizontal scrolling
  • Vertical scrolling
  • Page control to indicate how many photos are in the list
  • Works in both orientations (landscape, portrait)
  • Cell reuse (works on UICollectionVIew)

Download

You can download the project on GitHub.  If you have any questions, just ask it on  Twitter, put a comment below or open an issue on GitHub.

The component is also available via CocoaPods.

TNColorScrollViewController – easy scrollview with different color views

For a few iOS projects I needed a scrollview which had different UIViews with different background colors.  Because it came back regularly it became cumbersome to write the whole thing over and over again.  So yesterday I created a view controller which takes away the pain of writing it.

You can find the code on Github with a demo project on how to use it, but the steps are easy.

  1. Create an array with TNColorViewData objects and give it a background color or a reference to a custom UIView class (this class has to subclass TNColorView)
  2. Create a config object in which you add the array and have the possibility to set some extra properties so the view controller knows how to behave
  3. Present the view controller
  4. There is no step 4

If you have any requests, just put them in the comments or add an enhancement in the GitHub issue tracker!

TNSexyImageUploadProgress – A nice way to visualise an image upload in Objective-C

I’ve just pushed some code to GitHub to easily visualise an image upload in Objective-C.  Hope it could help some of you out and save you some time!  The class can be easily customised via various setters to change the radius, colors, etc.

image upload progress in objective-c

You can find the code on GitHub. If you have any requests, put them in the issues panel.  I’ve tested as many scenarios as I could, but if you find any bugs, please post them as well!

ps: don’t let the name mislead you, it isn’t really sexy. I just wanted to see the effect on clicks 😉

TNCheckBoxGroup – Custom checkboxes for Objective-C

There is now also a Swift version available: read about it here.

A few weeks back I pushed some code to GitHub to easily create checkboxes in Objective-C, but there were some limitations to the class. I’ve now updated the class so you can work with checkbox groups, like TNRadioButtonGroup.

Continue reading TNCheckBoxGroup – Custom checkboxes for Objective-C

TNRadioButtonGroup – Radio buttons for Objective-C

Radio buttons for Objective-C

I just pushed some code to GitHub to easily create radio button groups in Objective-C.

I’ve created 3 classes for the most common radio buttons, but it’s really easy to extend the class with your own requirements.  I’ve posted all the details on GitHub.  When you toggle the radio button there is an animation. You can always override the animation method if you would like to do some other animations.

Continue reading TNRadioButtonGroup – Radio buttons for Objective-C

TNCheckBox – A checkbox class for Objective-C

This class is no longer maintained…please check out TNCheckBoxGroup!

I just pushed some code to GitHub to create customisable checkboxes to use in your IOS projects.

As it happens with designers, you can’t always use the built-in UISwitch class.  So I took the time to create a few classes which are pretty customisable to have checkboxes without all the hassle.

Continue reading TNCheckBox – A checkbox class for Objective-C