2016-03-30 5 views
1

In meinem Projekt möchte ich mit wie diese Wie programmierte benutzerdefinierte Sammlung aussehen?

hier Platz enter image description here

SVGKImageView & UILabel programmatisch Zelle individuelle Ansicht entwerfen ist eine SVGKImageView & „Dadar“ ist ein UILabel.

Aber jetzt erhalte ich eine Ausgabe wie diese

enter image description here

Dies ist mein Code

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell 
{ 
    // intialize collection cell with media collection cell 
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("mediaCell", forIndexPath: indexPath) as! ViewContentMediaCollectionCell 

    // get the data from view model 
    let viewModelobj = mViewContentViewModelObj!.getViewContentData() 

    // set the page imageview frame with default size 
    var mSVGImageView = SVGKFastImageView(frame: CGRect(x: 0, y: 0, width: cell.frame.width, height: (50))) 

    // set the pageImageview with actual pageImage 
    mSVGImageView = SVGKFastImageView(SVGKImage: viewModelobj[indexPath.row].mContentPage) 

    // add page imageview in the cell 
    cell.contentView.addSubview(mSVGImageView) 

    // add the title label 
    let titleLabel : UILabel = UILabel(frame: CGRect(x: 0, y: cell.frame.height - 20, width: cell.frame.width, height: 20)) 

    // set the page title 
    titleLabel.text = viewModelobj[indexPath.row].mPageTitle 

    // add title label to the collection view cell 
    cell.contentView.addSubview(titleLabel) 

    // return the cell 
    return cell 

    } 
+0

verwenden Sie Einschränkungen –

+0

nein ... atleast nicht in der benutzerdefinierten Ansicht Zelle –

Antwort

0

Sie sollten eine benutzerdefinierte Ansicht erstellen, die eine Image und ein Label wie Ihr Design enthält dann hinzufügen zum contentView

+0

B Aber ich kann .svg Bild in ImageView nicht anzeigen. Also erstelle ich svgkimageview programmatisch. –