Custom UIView with transparent background

In this post I will describe how to add custom UIView objects with transparent bacgground to your project.

In the Things Speak app I have a custom UIView where the different charts are presented. It is a really simple one, two subviews are being added with the charts to a standard UI element. The topmost subview is expected to have transparent bacground to not hide the other one, while the lower one has extra contents like chart guide lines, scales, etc. I nearly spent 3 hours to find what the problem is, based on the forums it seemed no one had the same problem before. Now, that I know what is the solution, it is pretty logic.

To demonstrate it, I created a small example. Full source code can be downloaded from here.

First, let’s see the custom view. It has a draw() function where a circle or a rectangle will be drawn. On a custom background color with custom drawing color.

Let’s create an instance of this view with a red circle on a white background.

The result will be the same as we expected:

Adding the second view with 50% transparency black background and a blue rectangle:

The result will be this:

Pretty good, but we would like to see the circle and the expected result would be a grey-ish background through a semi-transparent view. This black is definitely not what we want.

The key is to set the isOpaque parameter of the window. According to Apple if the opaque parameter is true, for the best user experience and for better performance anything covered by the view will be fully skipped from rendering, even if the background was set to transparent. Actually the set backround will be used instead of anything under it. If we set white transparent background, the result will be gray, but the circle is not visible.

So change back the background to black and set the isOpaque to false right before we are attaching the second view to the main view:

After the isOpaque has been set, the output is now ok:

Finally, to support rotation, add this function to your main view:

 

Creating apps for kids

I’m that kind of dad who gives the iPad to my son once or twice a day. I accept that a parent sometimes needs 5-10 minutes break and the iPad could make this period even longer, if I would allow it. But we need a constant monitoring what is happening on the screen.

E.g. Youtube for Kids is not available everywhere around the world and it is not that hard to find anything inapropriate on the web.
So it is obvious you will watch all the videos together with your kids. And this is also true for mobile apps. When I find a new game interesting, I usually present the gameplay video to the family then we decide how to continue. If my son likes it, I’m purchasing the app first  to myself to see how it is working. If I accepted it, I’m installing it to the family iPad. Like I did with the Little Builders app.

Why? Because I found so many apps offering themself for free then presenting enormous amount of ads that the game becomes unplayable. It is more regular that free apps offering in-app-purchases for kids! And who gonna pay? Do they have bank accounts? Sallaries? Or they will constantly nag mom and dad to purchase more kitten food for a virtual pet? Nonsense.

App for kids shall serve educational purposes, not an other way to get more money from software development. If you can define what is the information your users can learn from your app, then it is good. If you can sell this in the $0-$5 range, better. If not, and the purpose is just to spend a lot of money in your app because there is no other option to continue playing, then it is a totally wrong way.

My other concern is the playability of the apps. Even in the under 5 category lot of apps are unplayable because there were no tests with the targeted audiences. I mean the app is not developd for small hands with lack of fine motor movements, and sometimes with glitching eyes-hands coordination. E.g. I was looking for a pipe builder game, where there are no other objectives, just to build a network of pipes. If there is a simulated water flow to show where are leaks, it is better. Free, unlimited play without any higher purposes.

The simplest app in the topic had at least 30 levels with increasing difficulty and limited playtime. It was also full of ads. Others were in the paid category with questionable gaming experience even for adults.

So this is why I am developing my next game for kids. And it will be free without IAP and ads. To show, it is not that hard to give something for the younger ones and have respect from their parents.

 

Finally, version 1.2 is out

In a mere 3.5 days the new version of my Thingspeak client app landed on App Store. Just to ket you know, the next beta is already provided to internal testers with many more functions. I just can’t wait to publish 1.3. 😀

Things Speak 1.2 is waiting for review now

After a couple of days of struggling with the iPhone screen I finally managed to release a new build with many long awaited features. One of the app store review gave me the idea to extend the capabilities of the app with more chart types like column or filled lines. Now both of them are in the app.

Also timescale, average and sum is available now to reduce the visible measured points on a 10..1440 minutes base. So if you have a lot of data in the last 3 months, there is now an option to see the trends by selecting different functions.

Timescale values are the real measurements, while average and sum is the mathematical representations for the given period.

I have added a feature to update the last opened channel when the app resumes from the background (if it was not terminated by the iOS due to memory issues), but a new button was also added to have manual refreshing options.

Two new buttons were added to have a more precise input for start and end dates. If these are set, the app will collect data between the given dates.

I hope all of you will enjoy the new features.