Jump to content

2 posts in this topic

Recommended Posts

Posted

Hey guys I followed Joka’s tutorial to give colour to my switches.

However it doesn’t seem to work for me.

Can anyone provide a solution for this? Here are my projects files:

Tweak.mm:

#import <Preferences/PSControlTableCell.h>
#import <Preferences/PSListController.h>

@interface PSSwitchTableCell : PSControlTableCell
- (id)initWithStyle:(int)style reuseIdentifier:(id)identifier specifier:(id)specifier;
@end
 
@interface SRSwitchTableCell : PSSwitchTableCell
@end
 
@implementation SRSwitchTableCell
 
-(id)initWithStyle:(int)style reuseIdentifier:(id)identifier specifier:(id)specifier {
 
    self = [super initWithStyle:style reuseIdentifier:identifier specifier:specifier];
   
if (self) {
        [((UISwitch *)[self control]) setOnTintColor:[UIColor blueColor]]; // Change the colour of the ON state UISwitch here
 
    }
    return self;
}
 
@end

@interface helloListController: PSListController {
}
@end

@implementation helloListController
- (NSArray *)specifiers {
	if (!_specifiers) {
		_specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
	}

	return _specifiers;
}

/* The "Visit iOSGods.com" link inside the Preferences button */
- (void)link {
        UIApplication *application = [UIApplication sharedApplication];
        NSURL *URL = [NSURL URLWithString:@"https://iosgods.com"];
        [application openURL:URL options:@{} completionHandler:^(BOOL success) {
            if (success) {
                //NSLog(@"Opened url");
            }
        }];
}
@end

// vim:ft=objc

Root.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>items</key>
	<array>
		<dict>
			<key>cell</key>
			<string>PSGroupCell</string>
			<key>footerText</key>
			<string>This text will appear under your first switch.</string>
                   <key>label</key>
                   <string>This is the new text</string>
		</dict>
		<dict>
                  <key>cellClass</key>
                   <string>SRSwitchTableCell</string> 
                   <key>cell</key>
                   <string>PSSwitchCell</string>
			<key>default</key>
			<false/>
			<key>defaults</key>
			<string>ks</string>
			<key>key</key>
			<string>key1</string>
			<key>label</key>
			<string>SwitchText1</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSGroupCell</string>
			<key>footerText</key>
			<string>This text will appear under your second switch.</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSSwitchCell</string>
			<key>default</key>
			<false/>
			<key>defaults</key>
			<string>ks</string>
			<key>key</key>
			<string>key2</string>
			<key>label</key>
			<string>SwitchText2</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSGroupCell</string>
			<key>footerText</key>
			<string>This text will appear under your third switch.</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSSwitchCell</string>
			<key>default</key>
			<false/>
			<key>defaults</key>
			<string>ks</string>
			<key>key</key>
			<string>key3</string>
			<key>label</key>
			<string>SwitchText3</string>
		</dict>
             <dict>
             <key>cell</key>
             <string>PSGroupCell</string>
             </dict>
             <dict>
             <key>cellClass</key>
             <string>SRSwitchTableCell</string>
             <key>cell</key>
             <string>PSSwitchCell</string>
             <key>default</key>
             <false/>
             <key>default</key>
             <string>ks</string>
             <key>key</key>
             <key>key4</key>
             <key>label</key>
             <string>New Button</string>
             </dict>
		<dict>
			<key>cell</key>
			<string>PSGroupCell</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSTextCell</string>
			<key>label</key>
			<string>Made by Ibrahim</string>
		</dict>
		<dict>
			<key>action</key>
			<string>link</string>
			<key>cell</key>
			<string>PSButtonCell</string>
			<key>icon</key>
			<string>[email protected]</string>
			<key>label</key>
			<string>Visit iOSGods.com</string>
		</dict>
	</array>
	<key>title</key>
	<string>Testing</string>
</dict>
</plist>

This is what it shows me in Settings:

 

spacer.png

Can someone tell me where I went wrong?

Posted (edited)

@Ibrahim 89 Did you check my reply for the missing thing for it to work?

 

This is what my file looks like.

(sorry no formatting)

 

#import <Preferences/PSListController.h>
#import <Preferences/PSSpecifier.h>
#import <Preferences/PSControlTableCell.h>


@interface PSSwitchTableCell : PSControlTableCell
 -(id)initWithStyle:(int)style reuseIdentifier:(id)identifier specifier:(id)specifier;
@end

@interface SRSwitchTableCell : PSSwitchTableCell
@end
 
@implementation SRSwitchTableCell
 -(id)initWithStyle:(int)style reuseIdentifier:(id)identifier specifier:(id)specifier {
 self = [super initWithStyle:style reuseIdentifier:identifier specifier:specifier];
 if(self) {
  [((UISwitch *)[self control]) setOnTintColor:[UIColor colorWithRed:0.90 green:0.50 blue:0.05 alpha:1.0]];
  [((UISwitch *)[self control]) setThumbTintColor:[UIColor blackColor]];
  [((UISwitch *)[self control]) setTintColor:[UIColor colorWithRed:0.30 green:0.20 blue:0.03 alpha:1.0]];
 }
 return self;
}
@end

Updated by Fadexz

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines