15 Oct 2015 0 comments

Unite is a conference that is run by Unity Technologies to promote their key product, the Unity gaming engine. It isn’t so much as a conference, but rather an experience. With a keynote being pre...

Read More
15 Oct 2015 0 comments

While I worked on creating the iOS Animations by Tutorials video series and the three editions of the iOS Animations by Tutorials book I got a lot of ideas how the existing anim...

Read More
15 Oct 2015 0 comments

Happy Wednesday – it’s time for our 3rd new book release as part of the iOS 9 Feast! Today, Aaron, Saul, Matthew, Pietro and I are happy to announce that Core Data by Tutorials Second E...

Read More
15 Oct 2015 0 comments

In this getting started with Core Data tutorial, you’ll write your very first Core Data app using Swift 2.0. You’ll see how easy it is to get started with all the resources provided in Xcode, fro...

Read More
15 Oct 2015 0 comments

When you create a Core Data app, you design an initial data model for your app. However, after you ship your app inevitably you’ll want to make changes to your data model. What do you do then – you...

Read More
15 Oct 2015 0 comments

As part of this year’s iOS 9 Feast, we are releasing a new video tutorial series every Thursday. This week, we are happy to release a brand new video tutorial series – Introducing Custom Cont...

Read More
15 Oct 2015 0 comments

There’s been a big hole in Spotlight on iOS for a long time. Although users can use it to find you app, they can’t see inside it — to all the content that they really care about. Currentl...

Read More
15 Oct 2015 0 comments

Storyboards have been around since iOS 5 and have received lots of upgrades and new features since then, including unwind segues for reverse navigation, universal storyboards for both iPhone and iP...

Read More

Latest Posts:

Digital Signature Application in iPhone


In this application we will see how to DigitalSignature draw in iPhone. So let see how it will worked.
Step 1: Open the Xcode, Create a new project using Empty Application . Give the application “DigitalSignature”.
Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.
Step 3: We need to create a ViewController class for this application. So select the project New file -> UIViewControllersubclass -> Next -> Give the class name DigitalSignatureView.
Step 4: Open the AppDelegate.h file and make the following changes:


#import <UIKit/UIKit.h>
@class DigitalSignatureView;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
DigitalSignatureView *digitalSignatureView;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) DigitalSignatureView *digitalSignatureView;
@end
Step 5: Open the AppDelegate.m file and make the following changes:
#import "AppDelegate.h"
#import "DigitalSignatureView.h"
@implementation AppDelegate
@synthesize window = _window,digitalSignatureView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor blackColor];
[self.window makeKeyAndVisible];
digitalSignatureView = [[DigitalSignatureView alloc]
initWithNibName:@"DigitalSignatureView"
bundle:nil];
[self.window addSubview:digitalSignatureView.view];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
}
- (void)applicationWillTerminate:(UIApplication *)application
{
}
@end
Step 6: In the DigitalSignatureView.h file, make the following changes:
#import <UIKit/UIKit.h>
@interface DigitalSignatureView : UIViewController
{
CGPoint point;
UIImageView *image;
BOOL mouseSwiped;
int mouseMoved;
}
@property (strong, nonatomic)IBOutlet UIImageView *image;
@end
Step 7: Double click the DigitalSignatureView.xib file and open it to the interface builder. Select the view from interface builder and bring up Attribute Inspector. Change the background color into black. Drag the imageView from the library and
place it to the view. Connect File’s Owner icon to the View and select image. Now save the .xib file , close it and go back to the Xcode.
Step 8: Open the DigitalSignatureView.m file, make the following changes:
#import "DigitalSignatureView.h"
@implementation DigitalSignatureView
@synthesize image;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren’t in use.
}
#pragma mark – View lifecycle
- (void)viewDidLoad
{
mouseMoved = 0;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = NO;
UITouch *touch = [touches anyObject];
if ([touch tapCount] == 2) {
image.image = nil;
return;
}
point = [touch locationInView:self.view];
point.y -= 20;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
currentPoint.y -= 20;
UIGraphicsBeginImageContext(self.view.frame.size);
[image.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width,
self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), point.x, point.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
image.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
point = currentPoint;
mouseMoved++;
if (mouseMoved == 10) {
mouseMoved = 0;
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if ([touch tapCount] == 2) {
image.image = nil;
return;
}
if(!mouseSwiped) {
UIGraphicsBeginImageContext(self.view.frame.size);
[image.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width,
self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), point.x, point.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), point.x, point.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
image.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end



Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment