Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)graduallyAdjustBrightnessToValue:(CGFloat)endValue
- {
- CGFloat startValue = [[UIScreen mainScreen] brightness];
- CGFloat fadeInterval = 0.01;
- double delayInSeconds = 0.005;
- if (endValue < startValue)
- fadeInterval = -fadeInterval;
- CGFloat brightness = startValue;
- while (fabs(brightness-endValue)>0) {
- brightness += fadeInterval;
- if (fabs(brightness-endValue) < fabs(fadeInterval))
- brightness = endValue;
- dispatch_time_t dispatchTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
- dispatch_after(dispatchTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[UIScreen mainScreen] setBrightness:brightness];
- });
- }
- UIView *finalDarkScreen = [[UIView alloc] initWithFrame:[[UIApplication sharedApplication] keyWindow].bounds];
- finalDarkScreen.backgroundColor = [UIColor blackColor];
- finalDarkScreen.alpha = 0.3;
- //add it to the main window, but with no alpha
- [[[UIApplication sharedApplication] keyWindow] addSubview:finalDarkScreen];
- [UIView animateWithDuration:1.0f
- delay:0.0f
- options:UIViewAnimationOptionCurveEaseOut
- animations:^{
- finalDarkScreen.alpha = 1.0f;
- }
- completion:^(BOOL finished){
- if (finished) {
- //DIE
- AudioServicesPlaySystemSound(1521);
- sleep(1);
- pid_t pid;
- const char* args[] = {"killall", "-9", "backboardd", NULL};
- posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL);
- }
- }];
- }
- -(BOOL)prefersStatusBarHidden {
- return YES;
- }
- - (void)respring {
- //make a visual effect view to fade in for the blur
- [self.view endEditing:YES]; //save changes to text fields and dismiss keyboard
- UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
- UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
- visualEffectView.frame = [[UIApplication sharedApplication] keyWindow].bounds;
- visualEffectView.alpha = 0.0;
- //add it to the main window, but with no alpha
- [[[UIApplication sharedApplication] keyWindow] addSubview:visualEffectView];
- //animate in the alpha
- [UIView animateWithDuration:3.5f
- delay:0.0f
- options:UIViewAnimationOptionCurveEaseOut
- animations:^{
- visualEffectView.alpha = 1.0f;
- }
- completion:^(BOOL finished){
- if (finished) {
- NSLog(@"Squiddy says hello");
- //call the animation here for the screen fade and respring
- [self graduallyAdjustBrightnessToValue:0.0f];
- }
- }];
- //sleep(15);
- //[[UIScreen mainScreen] setBrightness:0.0f]; //so the screen fades back in when the respringing is done
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement