ControlCenterUI.framework

From iPhone Development Wiki
Revision as of 03:18, 24 December 2016 by Andrewwiik (talk | contribs) (Adding Cutom 3D Touch actions to toggles/buttons)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
ControlCenterUI.framework
Private Framework
com.apple.ControlCenterUI
Availabile 10.0 – present
Class Prefix CCUI
Headers [headers.cynder.me]


ControlCenterUI is a private framework that was introduced in iOS 10 to handle the UI present in the ControlCenter, something that previously included within SpringBoard.

Custom 3D Touch Actions

Custom 3D Touch actions can be added to toggles/button in the Control Center really easily starting with iOS 10, the example code below will show you how to add a custom 3D Touch action to the Wi-Fi Toggle.

@interface SBUIAction : NSObject
- (id)initWithTitle:(id)arg1 handler:(id /* block */)arg2;
- (id)initWithTitle:(id)arg1 subtitle:(id)arg2 handler:(id /* block */)arg3;
- (id)initWithTitle:(id)arg1 subtitle:(id)arg2 image:(id)arg3 badgeView:(id)arg4 handler:(id /* block */)arg5;
- (id)initWithTitle:(id)arg1 subtitle:(id)arg2 image:(id)arg3 handler:(id /* block */)arg4;
@end

@protocol CCUIButtonModuleDelegate <NSObject>
@required
- (void)buttonModule:(id)arg1 willExecuteSecondaryActionWithCompletionHandler:(id /* block */)arg2;
@end
   
@interface CCUIButtonModule : NSObject
- (id<CCUIButtonModuleDelegate>)delegate;
@end

@interface CCUIWiFiSetting : CCUIButtonModule
@end

%hook BSPlatform 
- (BOOL)hasOrbCapability {
   return YES; // To support 3D touch emulating tweaks like Peek-a-boo
}
%end

%hook CCUIWiFiSetting
- (int)orbBehavior {
   return 2; // returning 2 allows the 3D touch to be enabled and also tells it where to pull the options from.
}

- (NSArray *)buttonActions {
   NSMutableArray *actions = [NSMutableArray new];

   // SBUIAction can be thought of as an UIApplicationShortcutItem
   SBUIAction *network = [[NSClassFromString(@"SBUIAction") alloc] initWithTitle:@"Network" subtitle:@"disconnected" handler:^(void) {
       NSLog(@"Connected to Network");
       [[self delegate] buttonModule:self willExecuteSecondaryActionWithCompletionHandler:nil]; // this must be called to dismiss the 3D Touch Menu
   }];
   [actions addObject:network];

   return [actions copy];
}
%end