随笔分类 - Swift
1
摘要:创建界面var webView : UIWebView!var toolBar : UIToolbar!let swiftWH = UIScreen.mainScreen().bounds.sizewebView = UIWebView(frame: CGRectMake(0, 20, swift...
阅读全文
摘要:创建UIWebView和UISegmentedControlwebView用于显示内容,segmentedControl用于切换读取内容的类型为了方便起见 用拖拉控件形式布局完界面/*使用UIWebView加载本地数据或资源有如下三种方式:1,使用loadHTMLString方法加载HTML内容2,...
阅读全文
摘要:创建ToolBarlet toolBar = UIToolbar(frame: CGRectMake(0, 20, 380, 44))self.view.addSubview(toolBar)添加控件let btn1 = UIBarButtonItem(barButtonSystemItem: .C...
阅读全文
摘要:创建DataPicker//创建DatePickerdatePicker = UIDatePicker(frame: CGRectMake(0, 50, 380, 200))//将日期选择器区域设置为中文,则选择器日期显示为中文datePicker.locale = NSLocale(localeI...
阅读全文
摘要:常用手势: 滑动,轻点,捏合,旋转,拖拽,长按1.滑动(快速滑动)let swipeUp = UISwipeGestureRecognizer(target: self, action: Selector("swipe:"))swipeUp.direction = UISwipeGestureRec...
阅读全文
摘要:创建scrollviewscrollView = UIScrollView()scrollView.delegate = selfscrollView.frame = self.view.boundslet imageView = UIImageView(image: UIImage(named: ...
阅读全文
摘要:创建并设置相关属性var stepper : UIStepper!//微调器var label : UILabel!stepper = UIStepper()stepper.frame = CGRectMake(50, 200, 280, 50)stepper.minimumValue = 0//最...
阅读全文
摘要://遵守协议时需要把必须遵守的协议都实现了否则报红UIPickerViewDelegate,UIPickerViewDataSource创建PickerViewpickerView = UIPickerView()pickerView.delegate = selfpickerView.dataSo...
阅读全文
摘要:自iOS8起,苹果就建议告警框使用UIAlertController来代替UIAlertView在ViewDidLoad中加载时报错 whose view is not in the window hierarchy! 视图没创建出来之前是不能弹出来的解决办法,延长时间加载1.一般的提示框func ...
阅读全文
摘要:introduced=2.0, deprecated=8.3 早已废弃 还是拥抱 UIAlertController 吧创建UIActionSheetlet actionSheel = UIActionSheet()actionSheel.addButtonWithTitle("取消")action...
阅读全文
摘要:introduced=2.0, deprecated=9.0 ios9已经废弃 建议使用UIAlertController创建AlertViewlet alertView = UIAlertView()alertView.title = "温馨提示"alertView.message = "UIAl...
阅读全文
摘要:创建UISliderlet slider = UISlider(frame: CGRectMake(50, 100, 280, 50))slider.backgroundColor = UIColor.clearColor()slider.minimumValue = 0//最小值slider.ma...
阅读全文
摘要:创建UIProgressViewlet progressView = UIProgressView(progressViewStyle:.Default)progressView.frame = CGRectMake(20, 100, 300, 0)self.view.addSubview(prog...
阅读全文
摘要:创建UISegmentedControllet items = ["选项一","选项二","选项三"]let segmented = UISegmentedControl(items: items)segmented.frame = CGRectMake(40, 20, 300, 35)self.v...
阅读全文
摘要:创建Switchlet mySwitch = UISwitch(frame: CGRectMake(100,100,0,0))mySwitch.tag = 101self.view.addSubview(mySwitch)开关与事件mySwitch.on = falsemySwitch.addTar...
阅读全文
摘要:创建TextViewlet textView = UITextView(frame: CGRectMake(50, 100, 280, 50))self.view.addSubview(textView)设置边框textView.layer.borderWidth = 1//边框宽度textView...
阅读全文
摘要:创建TextFielflet textField : UITextField = UITextField(frame: CGRectMake(50, 100, 280, 50))self.view.addSubview(textField)设置属性textField.borderStyle = UI...
阅读全文
摘要:创建ImageViewlet imageView = UIImageView(frame: CGRectMake(10, 100, self.view.frame.size.width-20, 400))imageView.backgroundColor = UIColor.orangeColor(...
阅读全文
摘要:创建Button let button = UIButton(type: .Custom) button.frame = CGRectMake(100, 100, 100, 100) button.backgroundColor = UIColor.oran...
阅读全文
摘要:创建Label let rect = CGRectMake(10, 100, 320, 100) let label : UILabel = UILabel (frame: rect) self.view.addSubview(label)Label常用属性 l...
阅读全文
1

浙公网安备 33010602011771号