Mindmajix

iPhone – Creating a User Interface Kit (UIKIT) – I

IMAGE VIEW:-

A UIImageView object displays a single image or a sequence of animated images in your interface. Image views let you efficiently draw any image that can be specified using a UIImage object. For example, you can use this class to display the contents of many standard image files, such as JPEG and PNG files. You can configure image views programmatically or in your storyboard file and change the images they display at runtime. For animated images, you can also use the methods of this class to start and stop the animation and specify other animation parameters. 

         Refer UIKIT Framework Fundamentals to have a quick glance at the various types of Classes.

1)  For Single Image Setting to image view:-

. h file:-

# import <UIKIT/UIKIT . H>
@ interface b8ImageviewViewController :UIViewController
{
IBoutlet      UIImageView     *imageView;
}
@end

.m file:-

# import “b8ImageViewViewController .h “
@ implementation  b8ImageViewViewController
-(void) view DidLoad
{
UIImage   *img  =  [  uIImage imageNamed :  @ “icloud-logo.jpg”];

// how to set background color

Img view . backgroundColor   =  [UIColor  blackColor];
[  img view  SetImage:  img];

// Setting  enabled

Imgview . enabled= YES;

// setting hidden

Imgview . hidden = No;

 // setting tag

 Imgview .tag  =2;

// How to set content mode

[ img view  setContentMode:  UIViewContentModeScaleAspectFit];
[super viewDidLoad];
 }

Screenshot_1814

2) image view animation:

.m file:-

-(void)  viewDidLoad
{
// Animation  with Imageview
NSArray  *aArray=  [NSArray  arraywithObjects:
                                     [UIImage imageNamed : @ “1.jpg”]
                                     [UIImage imageNamed :  @  “2.jpg”]
                                      nil];
Img view . animationImages  =  aArray;
Img view.  AnimationDuration  =   0.5;
Img  view. AnimationRepeatCount  =   -1;   infinite time
                                                                             Image display
;
                   By using this message start animation
}

UI alert view:-

.h file:-

# import  <UIKIT/UIKIT.H>
@ interface  alert  AlertViewActionSheetViewController: UIView controller
<UIAlertviewDelegate, UIActionSheetDelegate>
{
}
@end

. m file:-

# import “AlertViewActionSheetViewController .h”
@ implementation AlertViewActionSheetViewController .h
–(void)view Didload
{
UIAlertView   *  alert  = [[ UIAlertview alloc]
      Init with title    :   @  “ message”
       Message          :     @  “ hello  world //”
       Delegate           : self
CancelButtonTitle: nil
OtherButtonTitles : @  “yes”,  @ “No” ,  nil];
;
;
}
-(void) alertView  :(UIAlertView *) alertView
ClickedButtonAtIndex : (NSInteger )button index
{
NSLog  (@ “  alert view delegate called and button index is %d”, button index);
If(button index = = 0)
{
}
If (button index = = 1)
{
}
}

Screenshot_1816

UIActionSheet:-

. h file:-

#  import <UIKIT/UIKIT . h>
@ interface AlertViewActionSheetViewController:
                     UIViewController
<UIAlertViewDelegate, UIActionSheetDelegate>
{
}
@end

.m file:-

#  import  “ AlertViewActionSheetViewController .h”
@ implementation  AlertViewActionSheetViewController
-(void) view DidLoad
{
UIActionSheet     *  Sheet  =   [[UIActionSheet  alloc]
                                InitWithTitle:    @ “message”
                                   Delegate       :  self
CancelButtonTitle:  nil
DestructiveButtonTitle :  @  “ Destructive”
Other button titles      :   @  “ok”
                                               Nil];
[ sheet SetActionSheetStyle :
UIActionSheetStyleBlackTranslucent];
[  Sheet  ShowInView  :  selfView];
[Sheet  release];
}
-(void)  actionSheet  : (UIActionSheet *)  actionSheet
ClickedButtonAtIndex :  (NSInteger)  buttonIndex
{
NSLog (@ “ ActionSheet Delegate called and buttonindex is %d”, button Index);
If (buttonIndex = = 0)
{
}
If (buttonIndex = = Ø)
{
}
}

Screenshot_1817

UIColor:-

// preparing colors using RGB values:

UIColor   *  color  =   [  UIColor ColorWithRed :95
                                         Green:120
                                         Blue   :220
                                         Alpha :1];

// class methods:

UIColor   *  cColor   =   [UIColor red color];

// No Color:

 Self  ViewBackgroundColor = [UIColor  ClearColor]; 

//Convert Image to Color:

Self  ViewBackgroundColor = [UIColor ColorWithPatternImage:
                            [UIImage imageNamed : @ “1.jpg”]]

UIFont :-

UILabel     *  lbl;

// regular and size  is 18:

Lbl  font  =   [   UIFont SystemFontOfSize : 18];

// Bold:

Lbl  font  =   [   UIFont boldSystemFontOfSize : 20];

//Font Name:

Lbl .font =  [UIFont fontWithName :@  “vedina” Size:20];

UI SCREEN:-

// getting screen frame:

CGRECT rc =  [[  UIScreen  mainScreen] applicationFrame];

UIDevice:-

/*
For IMET - - No Coding in I phone, code having only
for UDID - - 40 digit for I phone
             32 digit for Iphone simulator
*/
UIDevice   *aDevice  =  [UIDevice CurrentDevice];
NSString    *  u did =  [ aDevice   uniqueIdentifier];
NSString  * devName  =  [ aDevice    name];
NSString  * devModel =  [aDevice   model];
NSString  * version  =  [ aDevice    SystemVersion];

// getting  batting  level:

Float      batterlevel   =   [a device batterylevel];
                             // 0 to 1,    -1  if battery  state
                                            Is un known. 

 

 

 


 

0 Responses on iPhone – Creating a User Interface Kit (UIKIT) – I"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.