Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Story Board Implementation #26

Open
mugsinc opened this issue Sep 23, 2015 · 3 comments
Open

Story Board Implementation #26

mugsinc opened this issue Sep 23, 2015 · 3 comments

Comments

@mugsinc
Copy link

mugsinc commented Sep 23, 2015

How can this be implement onto a StoryBoard With a UIView, is there a version of the line chart which has a story board. Please help

@awoodall
Copy link

You can add a graph to a UIView() by creating an outlet for your view then adding your graph to the subview.

@IBOutlet var LineGraphView: UIView!
lineChart = LineChart()

LineGraphView.addSubview(lineChart)

let horizontalConstraint = lineChart.centerXAnchor.constraintEqualToAnchor(LineGraphView.centerXAnchor)
let vertivalConstraint = lineChart.centerYAnchor.constraintEqualToAnchor(LineGraphView.centerYAnchor)
let widthConstraint = lineChart.widthAnchor.constraintEqualToAnchor(nil, constant: self.view.frame.size.width + 30)
let heightConstraint = lineChart.heightAnchor.constraintEqualToAnchor(nil, constant: 170)

NSLayoutConstraint.activateConstraints([horizontalConstraint, vertivalConstraint, widthConstraint, heightConstraint])

@ccabanero
Copy link

@mugsinc I was able to use this LineChart View with storyboards using the following workflow:

  1. Add a UIView to your target Storyboard scene.
  2. With the UIView selected, go to the Identity Inspector. Under the top Custom Class section, explicitly set the Class to 'Line Chart'
  3. Add the UIView as an IBOutlet to your associated Controller class. For example ... @IBOutlet weak var lineChart: LineChart!
  4. Because you have a UIView representing the ListView in a storyboard scene, add auto-layout constraints as needed.
  5. In your associated Controller class continue to configure the Line Chart programmatically per the docs

@arshadsk5
Copy link

As @ccabanero said it is true, just avoid addsubview() and addcontranints() code in your view controller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants