In an earlier post, I spoke about enabling AirPlay support to an AVPlayer object.
Here’s a complement to that post, it enables you to monitor the state of AirPlay (starting iOS7) and display a stand-in image where the AVPlayer object is placed. (AVPlayer will show a black screen when AirPlay is active).
Well, I’ve been dipping my toes in Swift for the past couple of months and I have grown a few extensions that I would like to share: an extension for String class and UIColor class…
Wouldn’t be nice to be able to access String instances and get sections of it (substring) as a new String but with a simple syntax?
Wouldn’t defining UIColor instances with a String make life easier for developers when working with graphical designers?
Since the introduction of iOS 7, there’s an abundance of articles that explain how to use iOS 7′s background fetch to download data for your apps while the phone is in it’s downtime.
Background fetch can be used to update weather information, traffic report status, load new articles, etc. It’s a way for your app to reach your server and update the user’s screen during downtimes (phone not being used, phone is sleeping and being charged).
iOS uses a bunch of factors before giving your app the precious time-slice (around 30sec max) in order for your app to do its business. The faster you execute the process, the more chances the OS will give you future time-slices. The more processor intensive you are, the less likely for the OS to give you time in the future.
This is all well and good, and I have recently launched an app update that uses this feature to the App Store.
What came next was perplexing…
This is something I spent a lot of time on, and maybe this will help someone out there. This trick is to remove the pesky padding at the right and left of rightBarButtonItem and leftBarButtonItem on a UINavigationBar (respectively).
One of staples of iOS interface is the ever pervasive UIActivityIndicatorView. It is used everywhere in iOS designs to indicate that the app is busy and that the user must wait.
The problem is that it is boring and needs a good scrub to refresh its design.
When working with graphic designers for interface design you get a lot of color codes like #17d3ff and #555 (basically HTML color codes) and using UIColor main methods could be a pain.
To set color #17d3ff using Obj-c
UIColor* color = [UIColor colorWithRed:0x17/255.0f green:0xd3/255.0f blue:0xff/255.0f alpha:1.0f];
It’s a mouthful.
Luckily nicklockwood has created an great Obj-c category for these specific needs. It has a lot of utility methods added like colorWithString which takes an HTML color codes directly
UIColor* color = [UIColor colorWithString:@"#17d3ff"];
Much much better, and it also keeps the readability of your design code much easier to follow.
I have also made a fork that includes some more utility functions like “darker/lighter” shorthands.
MPMoviePlayerController is the goto solution for a quick implementation of a video player in your iOS apps.
But sometimes, you want more control on the movie playing experience, that’s why there’s the AVPlayer. From what I understand, MPMoviePlayerController wraps AVPlayer for easy access, but if you want your own custom controls, skins, colours, whatever its best to use AVPlayer.
I’m always trying to remember how to define a block in obj-c, its one of these things I keep forgetting its syntax. I always end up scouring the internet for an example.
Apparently I’m not the only one, Mike Walker seems to suffer the same and put-up a site just for this! I’m putting this as a sticky for me