Is there a way to set up a NSCollectionView programmatically in Swift?

后端 未结 3 2123
猫巷女王i
猫巷女王i 2020-12-15 12:09

I\'m coming from the iOS development and I am wondering if there is a way to set up a NSCollectionView programmatically like a UICollectionView in

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 12:47

    For Swift 2.0, you will need to change the collectionView!.autoresizingMask line to:

    long hand:

    collectionView?.autoresizingMask = NSAutoresizingMaskOptions([NSAutoresizingMaskOptions.ViewWidthSizable,NSAutoresizingMaskOptions.ViewMaxXMargin,NSAutoresizingMaskOptions.ViewMinYMargin,NSAutoresizingMaskOptions.ViewHeightSizable,NSAutoresizingMaskOptions.ViewMaxYMargin])
    

    or short hand:

    collectionView?.autoresizingMask = NSAutoresizingMaskOptions([.ViewWidthSizable,.ViewMaxXMargin,.ViewMinYMargin,.ViewHeightSizable,.ViewMaxYMargin])
    

提交回复
热议问题