How to make tweaks.

Saturday 6th May, 2017



It’s surprising how many people think creating tweaks is too hard and just give up. This is not exactly true, yes some will find Objective C difficult to learn but once you get going it is not that bad, and let me just mention, I never went and learnt Obj-C before starting tweaks, I just dove in and gave it a go.

In this part of my tutorial series we will actually be making a tweak, not just a simple alert after a respiring but an actual tweak. In this tutorial I will guide you through inspecting views, properties, methods and instance variables or ivars for short. Let’s begin!

Inspect Element

Similar to Inspect Element on Chrome there are jailbreak tweaks that can achieve this on iOS. I use FLEXible and is available on the BigBoss repository. FLEXible provides many awesome debugging features but today we will just be using the select tool.

Once you have FLEXible installed you will see a new bar appear at the top of your screen. Click the select button and then tap on any element of the screen, if you are lucky it will highlight and you can then inspect that view. If something is in the way and you can’t select it you can click the views button and search for it. Once you have located and selected the view you wish to modify click views and click the “I” next to the view. This will take you to a page with all the details of that view.

For this example I inspected onto a control center button. I want to make them all have random background colors. I used FLEXible to see the Superclass of that button (the superclass is what the view will inherit it’s properties and such from). I can see that it says CCUIControlCenterButton so now I know what I need to hook.

Now What?

We now know what view we need to hook, so make a new project using Theos following the steps in the previous tutorial and load Tweak.xm into your text editor. We need to hook CCUIControlCenterButton and so I add the following to the tweak.xm.

%hook CCUIControlCenterButton

Then in that hook I add:


All UIViews have a layoutSubviews method and that method is called whenever a view gets updated. UIViews also have a backgroundColor property which allows you to set the background colour of that view. So to make it chose a random colour I add after the %orig which is essential.

NSInteger randomRed = arc4random()%255;
NSInteger randomGreen = arc4random()%255;
NSInteger randomBlue = arc4random()%255;
self.backgroundColor = [UIColor colorWithRed:randomRed/255.0f green:randomGreen/255.0f blue:randomBlue/255.0f alpha:1.0f];

This may look a little complicated so let’s run through it. First off we call the original Apple code, we don’t want to stop the buttons being a button. Then we create 3 random numbers between 0 and 255, the standard values for a RGB colour, then we create a UIColor using the colorWithRed:green:blue:alpha method which allows us to create any colour we want, we then set the background colour to be that random color.

The colour will be regenerated every time layoutSubviews is called so all the buttons should be different. This code should compile file so run make package install and let it do it’s thing.

Once Theos has installed the tweak onto your device you should see that the control center buttons are all different colours.

And thats it! We made a tweak using FLEXible and Theos!


In this tutorial, we set up and learnt how to use FLEXible to create a tweak, in the next tutorial we get more complicated than just hacking properties. Stay tuned!

To ensure you don't miss a new tutorial follow me on Twitter @LaughingQuoll.