Mike3355
Mike3355

Reputation: 12061

Adding images with PaintCode into Xcode 7 using Swift 2.0

I am trying to move a swift file that I exported from PaintCode 2 into my project. I did the following.

  1. Exported the project via PaintCode
  2. Moved the file into Xcode
  3. On my storyboard I put a UIView
  4. Clicked on the newly created UIView and selected the class that I imported from PaintCode.

Now I am looking a white box:

enter image description here

Now the file I got from PaintCode was of type NSObject which I knew couldn't be right so I changed it to UImage. Still getting the same result.

---------UPDATE-----------

I created a new Cococa Class of type UIView, and did the following:

@IBDesignable
class CareerButtonClass: UIView {

    //CareerButton.drawCanvas2()
     func drawCareerButton() {
        CareerButton.drawCanvas2()
    }
}

Then I named the custom class on IUView in the storyboard CareerButtonClass.

enter image description here

Here are what my files look like: enter image description here

Still getting the same result.

Upvotes: 0

Views: 825

Answers (3)

Tricertops
Tricertops

Reputation: 8512

The class you got from PaintCode is NSObject and it’s right. StyleKit is a collection of all graphics you use in your app.

To render the button, you need to override drawRect method in your UIView. And call the method to draw the Career Button.

@IBDesignable
class CareerButtonClass: UIView {

    override func drawRect(rect: CGRect) {
        StyleKit.drawCareerButton()
    }
}

See PaintCode FAQ #29.

Upvotes: 0

Mike3355
Mike3355

Reputation: 12061

For those who run by this post I finally found a good example here:

PaintCode Tutorial for Developers (Swift 2.0): Getting Started

Upvotes: 1

EmilioPelaez
EmilioPelaez

Reputation: 19912

That's because PaintCode exports a class with a collection of methods that you can use to draw the content.

Depending on the methods you choose, it can either generate a UIImage for you or you can call the code to draw in the current context.

It's up to you to implement where to use those methods.

Upvotes: 0

Related Questions