User Interface in SWIFT
## UIView
var myView = UIView(frame: CGRectMake(0, 0, 500, 300));
myView.backgroundColor = UIColor.redColor();
self.view.addSubview(myView);
## Label
var myLabel = UILabel(frame: CGRectMake(0, 0, 150, 40));
myLabel.text = " Learning Swift Programming: Chetan Anarthe ";
self.view.addSubview(myLabel);
## Button
var myButton = UIButton(frame: CGRectMake(0, 0, 280,40));
myButton.backgroundColor=UIColor.blueColor();
myButton.setTitle("SWIFT", forState: .Normal);
myButton.setTitleColor(UIColor.redColor(), forState: .Normal);
myButton.addTarget(self, action: "SELECT", forControlEvents: .TouchUpInside);
myButton.titleLabel.textAlignment=NSTextAlignment.Center;
self.view.addSubview(myButton);
## TextField
var myTextField = UITextField(frame: CGRectMake((0, 0, 200, 40));
myTextField.backgroundColor = UIColor.grayColor();
myTextField.text = "Chetan Anarthe";
self.view.addSubview(myTextField);
## UITextView
var myTextview = UITextView(frame:CGRectMake(0, 0, 200, 60));
myTextview.scrollEnabled = true;
myTextview.backgroundColor = UIColor.grayColor();
myTextview.textColor = UIColor.blueColor();
myTextview.textAlignment = NSTextAlignment.Center;
self.view.addSubview(myTextview);
## UIImageView
var myImageView = UIImageView(frame: CGRectMake(20, 400, 100, 150));
myImageView.image = UIImage(named: "image1.png");
self.view.addSubview(myImageView);
## Date Picker
var myDatepicker = UIDatePicker(frame:CGRectMake(20, 80, 280, 100));
myDatepicker.datePickerMode = UIDatePickerMode.Date;
self.view.addSubview(myDatepicker);
## Webview
var myWebview = UIWebView(frame:CGRectMake(20, 240, 280,310));
var myURL = NSURL(string:"http://www.chetansway.blogspot.in");
var myRequest = NSURLRequest(URL: myURL);
myWebview.scalesPageToFit = true;
myWebview.loadRequest(myRequest);
self.view.addSubview(myWebview);
## Alertview
var myAlertView = UIAlertView();
myAlertView.title = "SWIFT";
myAlertView.addButtonWithTitle("OK");
myAlertView.message="Learning SWIFT Programming";
myAlertView.show();
## Slider
var mySlider = UISlider(frame:CGRectMake(0, 0, 200, 20));
mySlider.minimumValue = 0;
mySlider.maximumValue = 100;
mySlider.continuous = false;
mySlider.value = 0;
mySlider.addTarget(self, action:"Value Change:", forControlEvents: .ValueChanged);
self.view.addSubview(mySlider);
## UISwitch
var mySwitch = UISwitch(frame:CGRectMake(0, 0, 50, 30));
mySwitch.setOn(true, animated: false);
mySwitch.addTarget(self, action:"switchValueDidChange:", forControlEvents: .ValueChanged);
self.view.addSubview(mySwitch);
var myView = UIView(frame: CGRectMake(0, 0, 500, 300));
myView.backgroundColor = UIColor.redColor();
self.view.addSubview(myView);
## Label
var myLabel = UILabel(frame: CGRectMake(0, 0, 150, 40));
myLabel.text = " Learning Swift Programming: Chetan Anarthe ";
self.view.addSubview(myLabel);
## Button
var myButton = UIButton(frame: CGRectMake(0, 0, 280,40));
myButton.backgroundColor=UIColor.blueColor();
myButton.setTitle("SWIFT", forState: .Normal);
myButton.setTitleColor(UIColor.redColor(), forState: .Normal);
myButton.addTarget(self, action: "SELECT", forControlEvents: .TouchUpInside);
myButton.titleLabel.textAlignment=NSTextAlignment.Center;
self.view.addSubview(myButton);
## TextField
var myTextField = UITextField(frame: CGRectMake((0, 0, 200, 40));
myTextField.backgroundColor = UIColor.grayColor();
myTextField.text = "Chetan Anarthe";
self.view.addSubview(myTextField);
## UITextView
var myTextview = UITextView(frame:CGRectMake(0, 0, 200, 60));
myTextview.scrollEnabled = true;
myTextview.backgroundColor = UIColor.grayColor();
myTextview.textColor = UIColor.blueColor();
myTextview.textAlignment = NSTextAlignment.Center;
self.view.addSubview(myTextview);
## UIImageView
var myImageView = UIImageView(frame: CGRectMake(20, 400, 100, 150));
myImageView.image = UIImage(named: "image1.png");
self.view.addSubview(myImageView);
## Date Picker
var myDatepicker = UIDatePicker(frame:CGRectMake(20, 80, 280, 100));
myDatepicker.datePickerMode = UIDatePickerMode.Date;
self.view.addSubview(myDatepicker);
## Webview
var myWebview = UIWebView(frame:CGRectMake(20, 240, 280,310));
var myURL = NSURL(string:"http://www.chetansway.blogspot.in");
var myRequest = NSURLRequest(URL: myURL);
myWebview.scalesPageToFit = true;
myWebview.loadRequest(myRequest);
self.view.addSubview(myWebview);
## Alertview
var myAlertView = UIAlertView();
myAlertView.title = "SWIFT";
myAlertView.addButtonWithTitle("OK");
myAlertView.message="Learning SWIFT Programming";
myAlertView.show();
## Slider
var mySlider = UISlider(frame:CGRectMake(0, 0, 200, 20));
mySlider.minimumValue = 0;
mySlider.maximumValue = 100;
mySlider.continuous = false;
mySlider.value = 0;
mySlider.addTarget(self, action:"Value Change:", forControlEvents: .ValueChanged);
self.view.addSubview(mySlider);
## UISwitch
var mySwitch = UISwitch(frame:CGRectMake(0, 0, 50, 30));
mySwitch.setOn(true, animated: false);
mySwitch.addTarget(self, action:"switchValueDidChange:", forControlEvents: .ValueChanged);
self.view.addSubview(mySwitch);
No comments:
Post a Comment