0
class MDCollectionViewLayoutAttributes : UICollectionViewLayoutAttributes
{
var color: UIColor = UIColor.whiteColor()
var image : UIImageView!
override func copyWithZone(zone: NSZone) -> AnyObject
{
let newAttributes: MDCollectionViewLayoutAttributes = super.copyWithZone(zone) as! MDCollectionViewLayoutAttributes
newAttributes.color = self.color.copyWithZone(zone) as! UIColor
newAttributes.image = UIImageView(frame:newAttributes.bounds)
newAttributes.image.image = UIImage(named:"Appetizer.png")
newAttributes.image = self.image.copyWithZone(zone) as! UIImageView// this is giving me an error
return newAttributes
}
}
мне нужно объявить изображение, чтобы использовать его в следующем коде, чтобы установить его в качестве фона раздела, но его дает мне ошибку.ошибка: Статический copyWithZone член не может быть использован, например типа UIImageView
override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]?
{
let attributes = super.layoutAttributesForElementsInRect(rect)
var allAttributes = [UICollectionViewLayoutAttributes]()
if let attributes = attributes
{
for attr in attributes
{
if (attr.representedElementCategory == UICollectionElementCategory.Cell && attr.frame.origin.x == self.sectionInset.left)
{
let decorationAttributes = SBCollectionViewLayoutAttributes(forDecorationViewOfKind: "sectionBackground", withIndexPath: attr.indexPath)
// decorationAttributes.color = UIColor.brownColor().colorWithAlphaComponent(1)
Любая помощь?
Есть ли какой-нибудь пример? или любую ссылку для примера? –