Mac开发之NSCollectionView使用以及自定义ite
2016-12-20 本文已影响1817人
代码行者
与iOS中的UICollectionView相似,在Mac开发中,我们也会常常用到NSCollectionView来展示内容,但在使用中,与iOS有较大差别,尤其对Mac开发新手来说,不得不到头文件中慢慢搜索,结果事倍功半,本文简示范基础用法,可以快速上手练习,好了,闲话少叙,开启工程实例,开发语言使用Swift3.0
创建工程

选择开发语言

添加NSCollectionView

设置约束

设置连线属性

添加自定义CollectionViewItem



实现代码(ViewController.swift)

CustomItem.swift

运行效果

Demo示例地址: