惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
Tenable Blog
Project Zero
Project Zero
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
S
Schneier on Security
Scott Helme
Scott Helme
S
Securelist
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
IT之家
IT之家
V
V2EX
F
Fortinet All Blogs
Simon Willison's Weblog
Simon Willison's Weblog
K
Kaspersky official blog
博客园_首页
T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
Spread Privacy
Spread Privacy
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
有赞技术团队
有赞技术团队
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
S
SegmentFault 最新的问题
AWS News Blog
AWS News Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost

博客园 - meetweb

IDEA 使用generator逆向工程生成pojo,mapper Ambiguous reference to member 'dataTask(with:completionHandle:)'错误 swift3.0 创建经典界面的九宫图 AlertDialog中使用ListView绑定数据 bootstrap table教程--后台数据绑定、特殊列处理、排序 bootstrap table教程--使用入门基本用法 jqGrid使用json实现的范例一 android logger的使用 通过反射获取DLL的类实现加载窗体 Visual 2015创建新项,缺少ADO.NET 实体数据模型的解决方法 在VisualStadio2015上使用EF6.0建立MySql数据库 事件使用(转 ) 使用Dotfuscator 进行.Net代码混淆 代码加密的方法 Git分布式版本控制系统学习笔记 免费SVN服务器笔记 如何设置mysql远程访问及防火墙设置 c# GridControl怎么换行 模拟Post登陆带验证码的网站 c#控制打印机杂项
swift3.0  代码创建经典界面的九宫图--优化篇
meetweb · 2017-09-22 · via 博客园 - meetweb

在上一篇只是简单实现了九宫图效果,本章需要形成APP界面九宫图效果

 override func viewDidLoad() {

        super.viewDidLoad()

        createnine()

    }

//九宫图算法

    func createnine(){

//高

        let kAppViewH:CGFloat=80

//宽        

let kAppViewW:CGFloat=80

//行个数

        let kColCount:Int=3

//间隔 

        let kStart:Int=20

        let MarginX:CGFloat=(self.view.frame.size.width-CGFloat(kColCount)*kAppViewW)/CGFloat(kColCount+1)

        let MarginY:CGFloat=10

        for i in 0 ..< 12 {

            let row:Int=i/kColCount;

            let col:Int=i%kColCount;

            let colF:CGFloat=CGFloat(col);

            let x=MarginX+CGFloat(col)*(kAppViewW+MarginX);

            let y=CGFloat(kStart)+MarginY+CGFloat(row)*(kAppViewH+MarginY);

            var imageView=UIImageView(image: UIImage(named: ""))

            imageView.frame=CGRect(x: 0, y: 0, width: 60, height: 60)

            //增加Lable

            var  nameLabel=UILabel(frame: CGRect(x:0, y: 60, width: Int(kAppViewW), height: 20))

            nameLabel.text="功能"

            nameLabel.textAlignment=NSTextAlignment.center

            nameLabel.backgroundColor=UIColor.blue

            //var btnBuuton=UIButton.button

//增加按钮 

            let btnButton=UIButton(frame: CGRect(x: 0, y: 20, width: 60, height: 60))

            btnButton.tag=i

            btnButton.setTitle("按钮", for: UIControlState.normal)

            btnButton.addTarget(self, action: #selector(btnClick(sender:)), for:

                .touchUpInside)

            let view=UIView(frame: CGRect(x: x, y: y, width: kAppViewW, height: kAppViewH))

            view.backgroundColor=UIColor.red

            view.addSubview(imageView)

            view.addSubview(nameLabel)

            view.addSubview(btnButton)

//加入视图

            self.view.addSubview(view)

        }  

    }

效果如下