{"id":426,"date":"2016-10-31T07:14:05","date_gmt":"2016-10-30T22:14:05","guid":{"rendered":"http:\/\/blue-bear.jp\/kb\/?p=426"},"modified":"2016-10-31T07:14:32","modified_gmt":"2016-10-30T22:14:32","slug":"swift-collectionview%e3%81%abreusableview%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%a6%e3%83%95%e3%83%83%e3%82%bf%e3%83%bc%e3%83%bb%e3%83%98%e3%83%83%e3%83%80%e3%83%bc%e3%82%92%e8%bf%bd%e5%8a%a0","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/swift-collectionview%e3%81%abreusableview%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%a6%e3%83%95%e3%83%83%e3%82%bf%e3%83%bc%e3%83%bb%e3%83%98%e3%83%83%e3%83%80%e3%83%bc%e3%82%92%e8%bf%bd%e5%8a%a0\/","title":{"rendered":"[swift] CollectionView\u306bReusableview\u3092\u4f7f\u7528\u3057\u3066\u30d5\u30c3\u30bf\u30fc\u30fb\u30d8\u30c3\u30c0\u30fc\u3092\u8ffd\u52a0"},"content":{"rendered":"<h2>CollectionView\u306bReusableview\u3092\u4f7f\u7528\u3057\u3066\u30d5\u30c3\u30bf\u30fc\u30fb\u30d8\u30c3\u30c0\u30fc\u3092\u8ffd\u52a0<\/h2>\n<h3>StoryBoard<\/h3>\n<p>StoryBoard\u306bCollectionView\u3092\u914d\u7f6e\u3057\u3066\u3001Reusableview\u3092\u30d5\u30c3\u30bf\u30fc\u30fb\u30d8\u30c3\u30c0\u30fc\u4f4d\u7f6e\u306b\u914d\u7f6e\u3002<br \/>\n\u305d\u308c\u305e\u308c\u306eReusableview\u306eIdentifier\u3092\u300cHeaderSection\u300d\u300cFooterSection\u300d\u3068\u6307\u5b9a<br \/>\n\uff0aIdentifier\u306e\u540d\u524d\u306f\u4efb\u610f<\/p>\n<h3>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h3>\n<pre>\r\n\/\/\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u500b\u6570\u3092\u8fd4\u3059\u30e1\u30bd\u30c3\u30c9\r\n    func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {\r\n        return 1\r\n    }\r\n    \r\n\/\/\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u8fd4\u3059\u30e1\u30bd\u30c3\u30c9\r\n    func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView\r\n    {\r\n        \r\n        if (kind == \"UICollectionElementKindSectionHeader\") {\r\n            \/\/\u30d8\u30c3\u30c0\u30fc\u306e\u5834\u5408\r\n            let testSection = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionHeader, withReuseIdentifier: \"HeaderSection\", forIndexPath: indexPath) as! TestCollectionReusableView\r\n            \r\n            \/\/\u30d8\u30c3\u30c0\u30fc\u306e\u80cc\u666f\u8272\u306f\u7d2b\u3001\u30e9\u30d9\u30eb\u306b\u30bb\u30af\u30b7\u30e7\u30f3\u540d\u3092\u8a2d\u5b9a\u3059\u308b\u3002\r\n            testSection.backgroundColor = UIColor(red: 0.7, green: 0.7,blue: 0.8, alpha: 1.0)\r\n            testSection.testLabel.text = sectionIndex[indexPath.section]\r\n            \r\n            return testSection\r\n            \r\n            \r\n        } else {\r\n            \/\/\u30d5\u30c3\u30bf\u30fc\u306e\u5834\u5408\r\n            let testSection = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionFooter, withReuseIdentifier: \"FooterSection\", forIndexPath: indexPath)\r\n            \r\n            \/\/\u30d5\u30c3\u30bf\u30fc\u306e\u80cc\u666f\u8272\u3092\u5909\u66f4\r\n            testSection.backgroundColor = UIColor(red: 0.5, green: 0.6,blue: 0.5, alpha: 1.0)\r\n            \r\n            return testSection\r\n            \r\n        }\r\n    }\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CollectionView\u306bReusa<\/p>\n","protected":false},"author":1,"featured_media":88,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/426"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=426"}],"version-history":[{"count":2,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/426\/revisions"}],"predecessor-version":[{"id":428,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/426\/revisions\/428"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media\/88"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}