Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Danesz/8c84bdd6071f3f85ef158881b809e56e to your computer and use it in GitHub Desktop.
Save Danesz/8c84bdd6071f3f85ef158881b809e56e to your computer and use it in GitHub Desktop.
Show a custom version of Apple's native OBWelcomeController when opening a preference bundle.
/*The file that you modify is the XXXRootListController.m file in your
preference bundle directory (XXX being the three characters that you chose for your preference bundle */
//I'm interfacing all the classes you'll need here. But don't forget to change $(BUNDLE_NAME)_PRIVATE_FRAMEWORKS = Preferences to $(BUNDLE_NAME)_PRIVATE_FRAMEWORKS = Preferences OnBoardingKit
#include "XXXRootListController.h"
@interface OBButtonTray : UIView
- (void)addButton:(id)arg1;
- (void)setStackViewTopConstraint:(NSLayoutConstraint *)arg1;
- (NSLayoutConstraint *)stackViewTopConstraint;
- (void)setEffectView:(UIVisualEffectView *)arg1;
@end
@interface OBBuddyContinueButton : UIButton
+ (id)buttonWithType:(long long)arg1;
@end
@interface OBWelcomeController : UIViewController
- (id)initWithTitle:(id)arg1 detailText:(id)arg2 icon:(id)arg3;
- (void)addBulletedListItemWithTitle:(id)arg1 description:(id)arg2 image:(id)arg3;
- (void)setButtonTray:(OBButtonTray *)arg1;
@property (nonatomic,retain) OBButtonTray *buttonTray;
@end
@interface UIImage (Private)
+ (id)_applicationIconImageForBundleIdentifier:(id)arg1 format:(int)arg2 scale:(double)arg3;
@end
OBButtonTray *btnTray;
OBWelcomeController *welcomeController;
@implementation XXXRootListController
- (NSArray *)specifiers {
if (!_specifiers) {
_specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self];
//For all the icons I'm just using app icons, but any image can be used.
welcomeController = [[OBWelcomeController alloc] initWithTitle:@"title" detailText:@"detail text" icon:[UIImage _applicationIconImageForBundleIdentifier:@"com.apple.MobileSMS" format:10 scale:[UIScreen mainScreen].scale]];
[welcomeController addBulletedListItemWithTitle:@"bullet list item" description:@"stuff blah stuff blah blah" image:[UIImage _applicationIconImageForBundleIdentifier:@"com.apple.MobileSMS" format:1 scale:[UIScreen mainScreen].scale]];
[welcomeController addBulletedListItemWithTitle:@"another item" description:@"things blah stuff description information" image:[UIImage _applicationIconImageForBundleIdentifier:@"com.apple.mobilesafari" format:1 scale:[UIScreen mainScreen].scale]];
[welcomeController addBulletedListItemWithTitle:@"last item" description:@"more stuff that matters" image:[UIImage _applicationIconImageForBundleIdentifier:@"com.apple.mobilephone" format:1 scale:[UIScreen mainScreen].scale]];
btnTray = [[OBButtonTray alloc] initWithFrame:welcomeController.view.frame];
//I removed the effect view because it covered the whole welcomeController with a blur view.
[btnTray setEffectView:nil];
//I honestly do not understand why this works. I change the constant of the topLayoutConstraint, and then I remove the constraint. I know that it is very hacky, but it works.
NSLayoutConstraint *topLayoutConstraint = [btnTray stackViewTopConstraint];
topLayoutConstraint.constant = (welcomeController.view.frame.size.height - (welcomeController.view.frame.size.height / 6)) * -1;
[btnTray setStackViewTopConstraint:nil];
OBBuddyContinueButton *continueButton = [OBBuddyContinueButton buttonWithType:UIButtonTypeSystem];
[continueButton addTarget:self action:@selector(dismissVC) forControlEvents:UIControlEventTouchUpInside];
[continueButton setTitle:@"Continue" forState:UIControlStateNormal];
[btnTray addButton:continueButton];
welcomeController.buttonTray = btnTray;
welcomeController.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentViewController:welcomeController animated:YES completion:nil];
}
return _specifiers;
}
-(void)dismissVC {
[welcomeController dismissViewControllerAnimated:YES completion:nil];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment