Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Tuesday, March 12, 2013

Custom Transition(s) Using QuartzCore

UIStroryBoard when you push view controllers, or segues, it doesn't let you customize too much. What I ended up doing was override the perform method and used QuartzCore Animations to customize our transitions. I subclassed UIStoryBoardSegue and overwrote the perform function.

Below to customize for Push or Pop then for Segues. (For segues remember to change the class to the custom class in IB).

To do it from a normal pop or push (this does cross fade animation, adjust it for yours):


   #import <QuartzCore/QuartzCore.h>


 - (IBAction)launch1990:(id)sender {
    CATransition* transition = [CATransition animation];
    transition.duration = .45;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionFade;
    [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"1990Storyboard" bundle:nil];
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"1990"];
    [self.navigationController pushViewController:vc animated:NO];
  }
 

To do it from segue:

 
//ZHCustomSegue.h
#import <Foundation/Foundation.h>

@interface ZHCustomSegue : UIStoryboardSegue

@end


//  ZHCustomSegue.m
#import "ZHCustomSegue.h"
#import "QuartzCore/QuartzCore.h"

@implementation ZHCustomSegue


-(void)perform {

    UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
    UIViewController *destinationController = (UIViewController*)[self destinationViewController];

    CATransition* transition = [CATransition animation];
    transition.duration = .45;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush,   kCATransitionReveal, kCATransitionFade
   //transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom



    [sourceViewController.navigationController.view.layer addAnimation:transition
                                                            forKey:kCATransition];

    [sourceViewController.navigationController pushViewController:destinationController animated:NO];
}

Sunday, January 10, 2010

Remote Assistance Script

Welcome to my first ghetto code and scripts blog.

Let's jump right to it. This first script I wrote is for offering remote assistance, and is helpful to IT Admins everywhere.


set shell = createobject("wscript.shell")
dim strComputerName

On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002

set objShell = wscript.createobject("wscript.shell")
strComputer = Wscript.Arguments.Item(0)

strComputer = InputBox("Enter PC Name or IP ADDRESS:","Input")

If strComputer <> "" Then
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
strEntryName = "SCForceOption"
dwValue = 0
objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, dwValue
If (Err.Number = 0) or (Err.Number = 9) Then
Else If (Not Err.Number = 0) or (Not Err.Number = 9) Then
wscript.Echo "Error: "& vbCrLf & strComputer & " not found or no access.."
End If
End If
End If


shell.run "hcp://CN=Microsoft%20Corporation,L=Redmond,S=Washington,C=US/Remote%20Assistance/Escalation/Unsolicited/Unsolicitedrcui.htm"
shell.AppActivate("Help and Support Center")
wscript.sleep 1500
'shell.sendkeys "{TAB 9}"
shell.sendkeys strComputer
wscript.sleep 500
shell.sendkeys "%c"
shell.sendkeys "%S"

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...