iOS
Wednesday, 18 October 2017
Friday, 16 January 2015
HOW TO SET IOS UI ELEMENTS FRAME WITH PERCENTAGE VALUES TO SUPPORT ALL IOS DEVICES WITH SINGLE FRAME(SINGLE LINE CODE)
HOW TO SET IOS UI ELEMENTS FRAME WITH PERCENTAGE VALUES TO SUPPORT ALL IOS DEVICES
WITH SINGLE FRAME(SINGLE LINE CODE)
* Set your user interface elements frame according to your device screen resolution percentage.
* you don't need to set separate frames for iphone 4,5,6,6+,ipad,ipad2,ipad mini.
* Set Single frame with percentage to support in all iOS devices.
Download the library files and sample code from the following URL:
USAGE:
1.Drag RKFrame.h and RKFrame.m files into your project
2.Import RKFrame.h file in .pch file or import in your view controller
3.set frame with x-position percentage,y-position percentage,width percentage,height percentage and pass you superview frame ,Please check Example
2.Import RKFrame.h file in .pch file or import in your view controller
3.set frame with x-position percentage,y-position percentage,width percentage,height percentage and pass you superview frame ,Please check Example
Example :
UIButton *rkFrameButton=[[UIButton alloc]initWithFrame:[RKFrame XpositionPercentage:25.0 YpositionPercentage:25.0 widthPercentage:50.0 heightPercentage:50 view:self.view.frame]];
UIView *view=[[UIView alloc] initWithFrame:[RKFrame XpositionPercentage:25 YpositionPercentage:80 widthPercentage:50 heightPercentage:15 view:self.view.frame]];
UIView *view1=[[UIView alloc] initWithFrame:[RKFrame XpositionPercentage:25 YpositionPercentage:25 widthPercentage:50 heightPercentage:50 view:view.frame]];
Run your project in all iOS Devices and check
Thank you
RK
Sunday, 13 July 2014
programmatically designing user interface without storyboards and xibs in swift language,Here you can check UI controls like UIButton,UIView,UILabel,UISwitch,UISlider,UIImageView,UIWebView,UIDatePicker
Creating swift project without storyboards and xibs
Programmatically designing user interface without storyboards and xibs in swift language,
Here you can check UI controls like UIButton,UIView,UILabel,UISwitch,UISlider,UIImageView,UIWebView,UIDatePicker in swift
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor=UIColor.whiteColor()
//******** creating label programmatically*******//
let label = UILabel(frame: CGRectMake(120, 80, 150, 100))
//label.center = CGPointMake(160, 284)
label.textAlignment = NSTextAlignment.Center
label.text = " ^Click the above button to move to next view controller <<< uiview"
label.numberOfLines=4
self.view.addSubview(label)
sliderlabel = UILabel(frame: CGRectMake(120, 240, 150, 100))
//label.center = CGPointMake(160, 284)
sliderlabel.textAlignment = NSTextAlignment.Center
sliderlabel.numberOfLines=4
self.view.addSubview(sliderlabel)
//******** creating button programmatically*******//
let button=UIButton(frame: CGRectMake(20, 20, self.view.frame.width-40, 40))
button.backgroundColor=UIColor.blueColor()
button.setTitle("Ravi Kumar", forState: .Normal)
button.setTitleColor(UIColor.yellowColor(), forState: .Normal)
button.alpha=0.6
button.layer.borderWidth=0.3
button.layer.cornerRadius=2
//*** button action***//
button.addTarget(self, action: "pressme", forControlEvents: .TouchUpInside)
button.titleLabel!.textAlignment=NSTextAlignment.Center
self.view.addSubview(button)
//******** creating UIView programmatically *********//
let view=UIView(frame: CGRectMake(20, 80, 100, 100))
view.backgroundColor=UIColor.yellowColor()
view.layer.borderColor=UIColor.blackColor().CGColor
view.layer.cornerRadius=25
view.layer.borderWidth=6
self.view.addSubview(view)
//******** creating textfield programmatically********//
let myTextField = UITextField(frame: CGRect(x: 20, y: 200, width: self.view.frame.width-40, height: 40.00))
myTextField.backgroundColor = UIColor.grayColor()
myTextField.placeholder=" Enter here"
//myTextField.text = " Enter here"
myTextField.borderStyle = UITextBorderStyle.Line
myTextField.secureTextEntry=true
self.view.addSubview(myTextField)
//******** creating UIslider ***********//
let slider=UISlider(frame:CGRectMake(20, 260, self.view.frame.width-40, 20))
slider.minimumValue = 0
slider.maximumValue = 100
slider.continuous = false
slider.value = 0
slider.addTarget(self, action: "sliderValueDidChange:", forControlEvents: .ValueChanged)
self.view.addSubview(slider)
//********** creating UISwitch programmatically *******//
let customSwitch=UISwitch(frame:CGRectMake(150, 300, 50, 30))
customSwitch.setOn(true, animated: false)
customSwitch.addTarget(self, action: "switchValueDidChange:", forControlEvents: .ValueChanged)
self.view.addSubview(customSwitch)
//********** creating UITextView programmatically *******//
let textview=UITextView(frame:CGRectMake(20, 330, self.view.frame.width-40, 60))
textview.scrollEnabled=true
textview.backgroundColor=UIColor.grayColor()
textview.textColor=UIColor.blueColor()
textview.textAlignment=NSTextAlignment.Center
self.view.addSubview(textview)
//********** creating UIImageView Programmatically******//
let imageView = UIImageView(frame: CGRectMake(20, 400, 100, 150))
let image = UIImage(named: "image.jpg")
imageView.image = image
self.view.addSubview(imageView)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func pressme(){
//******** navigation from one view controller to another *******//
self.navigationController!.pushViewController(secondViewController(), animated: false)
//******** creating UIalertview programmatically*******//
let alertView=UIAlertView()
alertView.title="RK"
alertView.addButtonWithTitle("OK")
alertView.message="Now you are in second view controller"
alertView.show()
}
func sliderValueDidChange(slider: UISlider) {
sliderlabel.text=String(slider.value)
}
func switchValueDidChange(aSwitch: UISwitch) {
sliderlabel.text="switch pressed"
}
}
Download Source Code here
Friday, 11 July 2014
Programmatically creating button in swift language for ios
var button=UIButton(frame: CGRectMake(20, 20, 280, 40));
button.backgroundColor=UIColor.blueColor();
button.setTitle("ravi kumar", forState: .Normal);
button.setTitleColor(UIColor.yellowColor(), forState: .Normal);
button.alpha=0.2;
button.layer.borderWidth=0.3;
button.layer.cornerRadius=2;
button.addTarget(self, action: "pressme", forControlEvents: .TouchUpInside);
button.titleLabel.textAlignment=NSTextAlignment.Center;
self.view.addSubview(button);
Subscribe to:
Posts (Atom)