import UIKit
class ViewController: UIViewController,UITableViewDataSource {
var submitButton : UIButton!
var nameLabel : UILabel!
var passwordLabel : UILabel!
var userText : UITextField!
var passwordText : UITextField!
var loginDateText : UITextField!
var loginDatePicker:UIDatePicker!
var backImage:UIImageView!
var tableView:UITableView!
var items :NSMutableArray?
override func viewDidLoad() {
println("load Controller")
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//label define
nameLabel=UILabel()
nameLabel.frame=CGRectMake(0, 20, 100, 30)
nameLabel.text="用户名"
nameLabel.textAlignment=NSTextAlignment.Center
nameLabel.textColor=UIColor.greenColor()
userText=UITextField()
userText.frame=CGRectMake(110, 20, 100, 30)
userText.text="用户名"
userText.textAlignment=NSTextAlignment.Center
userText.textColor=UIColor.grayColor()
userText.borderStyle=UITextBorderStyle.Bezel
passwordLabel=UILabel()
passwordLabel.frame=CGRectMake(0, 60, 100, 30)
passwordLabel.text="密码"
passwordLabel.textAlignment=NSTextAlignment.Center
passwordLabel.textColor=UIColor.greenColor()
passwordText=UITextField()
passwordText.frame=CGRectMake(110, 60, 100, 30)
passwordText.text="密码"
passwordText.textAlignment=NSTextAlignment.Center
passwordText.textColor=UIColor.grayColor()
passwordText.secureTextEntry=true//密码
passwordText.borderStyle=UITextBorderStyle.Line//边框
loginDatePicker=UIDatePicker()
loginDatePicker.datePickerMode=UIDatePickerMode.Date
loginDatePicker.locale = NSLocale(localeIdentifier: "zh_CN")
loginDateText=UITextField()
loginDateText.frame=CGRectMake(0, 100, 100, 30)
loginDateText.text=loginDatePicker.date.description
loginDateText.textAlignment=NSTextAlignment.Center
loginDateText.inputView=loginDatePicker
backImage=UIImageView(frame:self.view.bounds)
backImage.image=UIImage(named:"mainBack")
//button define
submitButton=UIButton() //实例化
submitButton.frame=CGRectMake(0,140,200,30)//大小、位置
submitButton.backgroundColor=UIColor.redColor()//背景色
submitButton.setTitle("登录",forState:UIControlState.Normal)//文本
submitButton.addTarget(self,action:"submitInfo:",forControlEvents:UIControlEvents.TouchUpInside)//事件
var nsd = NSData(contentsOfURL:NSURL.URLWithString("http://ww2.sinaimg.cn/bmiddle/632dab64jw1ehgcjf2rd5j20ak07w767.jpg"))
var img = UIImage(data: nsd);
var vImg = UIImageView(image: img);
// vImg.frame.origin = CGPoint(x:0,y:220);
vImg.frame = CGRect(x:0,y:220,width:60,height:60);
submitButton.setBackgroundImage(img, forState: UIControlState.Normal)
tableView=UITableView()
tableView.frame=CGRectMake(0, 200, 400, 400)
tableView.dataSource=self
self.items = NSMutableArray()
self.items?.addObject("abc")
self.items?.addObject("hhh")
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
self.view.addSubview(backImage)
self.view.addSubview(loginDateText)
self.view.addSubview(passwordLabel)
self.view.addSubview(passwordText)
self.view.addSubview(userText)
self.view.addSubview(nameLabel)
self.view.addSubview(submitButton)
self.view.addSubview(vImg);
self.view.addSubview(tableView);
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func submitInfo(button: UIView) {
let alert = UIAlertView()
alert.title = "计时完成!"
alert.message = userText.text+passwordText.text
alert.addButtonWithTitle("OK")
alert.show()
}
func tableView(tableView: UITableView!, titleForFooterInSection section: Int) -> String! {
return "foot"
}
func tableView(tableView: UITableView!, titleForHeaderInSection section: Int) -> String! {
return "header"
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let cell = tableView .dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
cell.textLabel.text = self.items?.objectAtIndex(indexPath.row).stringValue
return cell
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
{
return self.items!.count
}
}
- 大小: 232.5 KB
分享到:
相关推荐
AVAudioPlayer 的音频播放的界面搭建,功能实现。
SwiftPlantUML 使用此命令行界面(CLI)和Swift包从swift代码生成UML类图。 使用一个或多个Swift文件作为图表的输入,以可视化class , struct , protocol , enum和extension类型及其实例和静态成员,以及它们的...
主要特征: iPhone和iPad支持自适应用户界面支持RGB和HSB颜色模型有据可查兼容iOS 8.0(iPhone和iPad)及更高版本预习苹果手机的iPad 例子要运行示例项目,请克隆存储库,然后首先从Example目录运行pod install 。...
以编程方式或在界面生成器中创建菜单 要求 iOS 9.0以上 Xcode 9.0以上 迅捷4.0+ 例子 要运行示例项目,请克隆存储库,然后首先从Example目录运行pod install 。 安装 DSDMenu可通过。 是Swift和Objective-C Cocoa...
SwiftJQ为您提供了一个本机界面,用于在macOS,iOS,tvOS和watchOS上执行 。 将Swift中的JSON处理提升到一个新的水平! :rocket: 为什么要在Swift中使用jq? jq是用于转换JSON的出色工具。 使用SwiftJQ您可以在...
Swift 使用Storybaord的状态保存例子
API平台管理员 API Platform Admin是一个工具,可以为任何支持API自动创建漂亮的(材料设计)和功能齐全的管理界面,包括但不限于使用创建的所有API。 根据API-first范例,生成的管理是100%独立的单页应用程序,不...
WKWebView 用户界面滚动视图界面视图要求Xcode 9+ 斯威夫特 4.0+ iOS 10.0+安装Swift 兼容性要使用 Swift 4.0,请使用 MXScroll v.0.1.0。 要使用 Swift 4.1,请使用 MXScroll v.0.1.2。 要使用 Swift 5.0,请使用 ...
UIWindowTransitions动画rootViewController过渡这是一个小项目,用于演示如何用一小段代码实现UIWindow的rootViewController过渡。...一个典型的例子可能是初始的入职与应用主界面之间的过渡(即UITabBarControlle
kedro diff旨在成为一个熟悉的界面,用于比较历史中的两点。 Git diff是出色的工具,但通常过于细化,无法查看管道中发生了什么变化。 kedro diff旨在成为更高级别的熟悉工具,以便我们可以看到节点的更改(名称,...
目录预习iPhone界面: iPad介面:优点 同时支持Swift(v2.2和v3.0)和Objective-C 支持所有方向 支持iPad 支持自动布局示范项目完全可行的例子; 在Objective-C和Swift中; 被包含在内。 如果您想自己尝试,只需下载...
现在支持swift 5.x pod 'RxCocoa-Texture' , '3.x.x' 永远欢迎您的贡献! 概念 RxCocoa提供了对Cocoa和Cocoa Touch框架的扩展,以利用RxSwift。 Texture提供了各种基本的UI组件,例如ASTableNode,ASControlNode,...
命令行界面,用于操纵Safari的Cookie存储 用法 cookieutil list :显示所有cookie cookieutil delete <domain> <path> <name> :删除cookie 例子 删除所有名称以“ __utm”开头的cookie cookieutil list | awk '$...
所有主要包装管理器均可提供:Cocoapods,Cartage和Swift包装管理器 目录 代表们 例子 作者 屏幕截图 更新用户界面警报 可跳过的警报 不可跳过的警报(默认) 阻止警报 自定义UILabel和UITableView页脚 四个...
欢迎使用Animation ,这是一个使用Swift编写样式动画的环境。 例子 自然,动画很容易生成: 当然,在Xcode中运行时,动画清晰而流畅。 您在上方看到的是GIF动画。 静态图像也可以生成,例如: 注意:此处显示的...
动画片欢迎使用Animation ,这是一个使用Swift编写样式动画的环境。例子自然,动画很容易生成: 当然,在Xcode中运行时,动画清晰而流畅。 您在上方看到的是GIF动画。 静态图像也可以生成,例如: 注意:此处显示的...
动画片欢迎使用Animation ,这是一个使用Swift编写样式动画的环境。例子自然,动画很容易生成: 当然,在Xcode中运行时,动画清晰而流畅。 您在上方看到的是GIF动画。 静态图像也可以生成,例如: 注意:此处显示的...
在第一次安装App, 常常会出现一个引导界面,实现引导页部分透明,部分蒙层的引导, 网上也没有很好的实现demo,自己就用消息链写了一个很简单的例子,供大家参考。