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 lets 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.

Table of Contents: iPhone UIKIT - 1

Refer to 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 
@ 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 the 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];
 }
Inclined to build a profession as IOS Developer? Then here is the blog post on iPhone Development Certification Training.

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
}

MindMajix Youtube Channel

UI alert view

.h file:-

# import  
@ interface  alert  AlertViewActionSheetViewController: UIView controller
{
}
@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)
{
}
}
Related Article: Frequently Asked iPhone Interview Questions & Answers

UIActionSheet

. h file:-

#  import
@ interface AlertViewActionSheetViewController:
                     UIViewController

{
}
@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 = = Ø)
{
}
}

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. 

Job Support Program

Online Work Support for your on-job roles.

jobservice

Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:

  • Pay Per Hour
  • Pay Per Week
  • Monthly
Learn MoreGet Job Support
Course Schedule
NameDates
IOS Development TrainingDec 14 to Dec 29View Details
IOS Development TrainingDec 17 to Jan 01View Details
IOS Development TrainingDec 21 to Jan 05View Details
IOS Development TrainingDec 24 to Jan 08View Details
Last updated: 03 Apr 2023
About Author

Ravindra Savaram is a Technical Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.

read less