Sur*_*gch 3 background image ios uicollectionviewcell swift
我曾经假设将背景图像添加到a中很容易UICollectionViewCell,但是我很难搞清楚它.我有一个这样的边框图像,我想添加到我的每个单元格中UICollectionView.
border.png
我看不到在Interface Builder中添加它的选项,我不确定在UICollectionViewCell编程上使用哪种方法.
我见过这些类似的问题:
UICollectionView,而不是UICollectionViewCell)我知道这是一个老问题,有一个公认的答案.但为什么不像这样设置单元格的边框:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
{
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath)
cell.layer.borderWidth = 1.5
cell.layer.borderColor = UIColor.blueColor().CGColor
cell.layer.cornerRadius = 4
return cell
}
Run Code Online (Sandbox Code Playgroud)
这样你就不需要使用图像了.只需调整borderWidth和cornerRadius,直到获得所需的效果.
| 归档时间: |
|
| 查看次数: |
6284 次 |
| 最近记录: |