Apple Swfit UI控件实现

本文介绍了Apple的Swift编程语言中UI控件的实现,通过示例代码和资源链接,帮助开发者掌握Swift UI的使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

不下载你会后悔的~~

下载地址:https://github.com/HunkSmile/Swift.git

// UILabel
var label = UILabel(frame: self.view.bounds)
label.backgroundColor = UIColor.clearColor()
label.textAlignment = NSTextAlignment.Center
label.font = UIFont.systemFontOfSize(36)
label.text = "Hello, Swift"
self.view.addSubview(label)
// UIButton
var button = UIButton.buttonWithType(UIButtonType.System) as? UIButton
button!.frame = CGRectMake(110.0, 120.0, 100.0, 50.0)
button!.backgroundColor = UIColor.grayColor()
button?.setTitleColor(UIColor.redColor(), forState: UIControlState.Normal)
button!.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Highlighted)
button?.setTitle("Touch Me", forState: UIControlState.Normal)
button?.setTitle("Touch Me", forState: UIControlState.Highlighted)
button?.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
button!.tag = 100
self.view.addSubview(button)
// UIImageView
var image     = UIImage(named: "swift-hero.png")
var imageView = UIImageView(frame: CGRectMake((CGRectGetWidth(self.view.bounds) - image.size.width) / 2.0, 120.0, image.size.width,
image.size.height))
imageView.image = image
self.view.addSubview(imageView)
// UISlider
var slider = UISlider(frame:CGRectMake(60.0, 120.0, 200.0, 30.0))
self.view.addSubview(slider)

                
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值