I am Nguele

My name is Jean-Dominique Nguele and this is my blog. FLVCTVAT NEC MERGITVR

Tag Archives: iOS


Avoid App Store rejection when submitting 3rd party based app

Reading Time: 2 minutes

A couple of days ago I submitted my first personal app to the Apple App Store. I know it can be surprising considering the few years I spent doing iOS development professionally. You may know this but I was more into Windows phone from its inception until Microsoft decided to murder it a few months ago. As a result, I fully switched to Apple, from the phone to the watch to the mac. Still kept my Windows laptop though.

Back to today’s topic, App Store rejection. I built some app to keep track of my crypto spendings. After a couple weekends working on it, I decided to publish it and see how people react to it. Unfortunately, the reviewers rejected the app because I did not provide a demo account for it.

Giving my personal account with my money in it was out of the question. Creating a new test account on Coinbase requires real data, identity and phone verification. By the way, I actually tried that and got locked out of my account just after using my phone to verify the test account. Do not try this at home! Not only it sucks, but it also turns out to be against their terms of use. If someone from Coinbase reads this, please do not delete my account I deleted the test one already.

After some back-and-forth trying to explain the situation and linking in Coinbase’s terms of use they eventually suggested that I send them a video. Yes, a video showing how to use the app. I instantly grabbed my phone and recorded a quick video showing my screen login in using Coinbase OAuth2 login. Since I had Face ID enabled, I did not have to enter my password so it was safe. The following day, they reviewed it again and approved it. You can download CoinzProfit now to have a look if you want to. Also if you do not use Coinbase but another exchange you can like/follow the Facebook page to have updates on the next exchanges I will integrate to it.

CoinzProfit App Store

Click that link and get that app!

Set tint color on an image in a NSAttributedString

Reading Time: 4 minutes

Introduction

Hi everyone, I have been working, for a few days now, on a project that requires to make an app fully customisable from a configuration file. I was coding and coding and coding, extracting color definitions, applying tints on images, when I ran into an issue. I could not apply tint over a mutable attributed string, nor simple attributed string for that matter. So I was there, looking at my NSAttributedString and my NSTextAttachment without any property allowing me to change only the image color.

It turns out that you actually can apply a color on your attributed string, I don’t know about the underlying magic when using attributed but it seems that you can apply your text color on an image embedded via your text attachment.

Let’s get started

Setting up the UI

First you create your single view project.

Create single view application

Create single view application

Set project name

Set project name

Then you go on your main storyboard (Main.storyboard) and add a label, that you will link to your view controller code (here as labelWithColoredImage).

Label setup

Label setup

Here is what your code should look like:

And that’s it terms of UI setup for now. Now you can run your app to be sure it’s behaving properly and that the label appears.

Simulator capture of a single label

Now the basic NSAttributedString implementation

Now let’s get our hands dirty with the coding part. First let’s update the text and change its color only using the textColor property only. Let’s add the following lines in the viewDidLoad function and run the app again.

First attempt with red color with no magic of NSAttributedString

First attempt with red color

Then we can observe that the text is red. One minor issue is that it doesn’t fit the screen so we can add contraints to the label to center it and make it responsive. Let’s add the text attachment magic now. It’s time to add an image to the project, I just added the image “swift_logo.png” in the project, drag-n-drop works as well as right clicking in the project and selecting “Add files to <ProjectName>”.

Image added to the project

Image added to the project

Let’s create our attributed string now with the text attachment, I will have the text over two lines to show how the image is now part of it and due to the image color I change the text color to blue so you can see the difference.

Another run!

Blue text, original image, thank you NSAttributedString

Blue text, original image

There you have it! Your image integrated within text. Now let’s check what happens if you render your image as a template. You need to replace this line  let image:UIImage=UIImage(named:"swift_logo")!  with  let image: UIImage = UIImage(named: "swift_logo")!.imageWithRenderingMode(.AlwaysTemplate) then run the app again.

Everything is blue now

Everything is blue now

Giving the image a color of its own different from the source one

Now the image is the same color as the text, for some of you it could be enough but we can go a little bit further by giving specifically to the image a color of its own. You can add the following lines before the assignment of the NSAttributedString to labelWithColoredImage.

Basically these lines say to color in green the character from the index matching the character after stringToDisplay for as long as the text attachment length. Now let’s run the app again.

The final step with NSAttributedString

The final step

And there you are, you know know how to apply a different color to an image through a NSAttributedString.

Conclusion

The source code is available on Github

There is one thing to keep in mind though, there must always be a space before the text attachment containing the image in you NSAttributedString otherwise it will not work. I am not quite sure wether the need to add a space is a bug or if it is actually given access to a hidden feature. Either way, happy coding !