Dev:ControlCenterUI.framework

From The Apple Wiki
ControlCenterUI.framework
Private Framework
Availabile10.0 – present
Class PrefixCCUI


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