I add a sublayer to create pie charts in my swift code. To optimize the view for different devices, I would like to position the text labels which I put on the view in the storyboard in relation to this layer ("build a group").
Is it possible to position labels in a layer? How can I do that?
Sure it's possible. You can create CATextLayer objects and add them as sublayers of your pie chart view's layer.
If you mean is it possible to put UILabel objects inside your layers, then the answer is no. Views can contain layers, but layers can't contain views.
Related
I am trying to add the CPTLegend in uiview how can i add.Basically many people adding in Graph hosting view. Any idea?
All visible parts of a Core Plot graph, including the legend (drawn by CPTLegend), are Core Animation layers that are derived from a common superclass, CPTLayer. These layers rely on the hosting view to set up the coordinate transform and event handling and to handle layout changes.
Why do you need to have a legend that is not attached to a graph? CPTLegend depends on plots both to determine the contents of the legend and to actually draw it. These plots are normally part of a graph, so you should have one available to use as a host for the legend.
Enlarge the hosting view to cover the whole area where the pie chart and legend should appear. Change the centerAnchor of the pie chart to move it away from the center of the hosting view and position the legend on the other side of the graph. The separator view can be placed on top of the hosting view to separate the plot from the legend. Note that Core Animation hosting views don't allow subviews, so it needs to be a sibling (i.e., have the same superview) of the hosting view, not a subview.
Hope you people doing great.I am new to Core Plot api and need your suggestion.I want to customize x index of plot and wants to add icon and label to each index.As I have searched , I got to make policy none to index but I want to add image to each label.Help will be much appreciated.
Custom axis labels don't have to be just text. The label's contentLayer can be any CPTLayer. Depending on what you're trying to achieve, you could render your text and label into an image and use that as the fill for a CPTBorderedLayer, add the icon (in a bordered layer) as a sublayer to the text layer for the label, or even create a custom CPTLayer subclass that draws everything the way you want it.
I have a custom table view and want it to look like this...
(source: pulsewraps.co.uk)
The image is loaded via async and the two lines come from two different arrays. I can get all the data in fine I just don't know how to lay it out.
I want:
the black gradient to overlay the image
the two lines of text to be within the black gradient box
the image to fill the table row to cover it and keep it's aspect ratio
the black gradient box to be pinned/constrained to the bottom of the image so that is either line of text is larger than two lines it covers more of the image and doesn't drop below it.
I fill the table data in a loop according to the number of records in my array which is populated by json.
I have managed to do the layout in android but can't get my head around ios.
Any help much appreciated.
If you're using autolayout, you'll want to constrain the labels to the bottom and to each other. Then put the gradient view behind the labels and constrain the top of the gradient to the top of the top label.
You'll have to handle drawing the gradient yourself, either use an image in an image view and set it to scale to fill, or subclass UIView and add a little bit of code to drawRect: The first is probably easier, the second will produce a more uniform gradient if it has to be scaled.
I would like to split my tableview's layer into two layers. Like this I will be able to transform one of them.
How can I manage that ?
Thanks a lot !
What do you mean? How do you want to split the table view's layer? You can use my UITableView category in LTKit to grab the rects of interest from the table view (the section headers, the sections themselves, all the visible table view cell rects, etc.): https://github.com/LucasTizma/LTKit/blob/master/LTKit/Categories/UITableView%2BLTKAdditions.m
Using this, you can easily grab the table view's layer as an image representation and then split up that image into sublayers you can then transform or animate as I've done here: http://f.cl.ly/items/0s2S101b1E2e3N0D431m/Screen%20Recording%203.mov
Hello,
Looking for insight from the gurus.
I need a stack of 3 views:
A: View containing various buttons, text inputs.
B: Custom view containing a large view (B2) that moves and rotates and contains multiple subviews and another fixed view (B1) that has a custom gradient transparency mask.
C: Image view containing a background image
I can't figure out how to get the B1 layer working. I can make the gradient but am unsure on how to apply the mask so it only affects the transparency of the subviews of B2. I need the background (C) to show through all the way to the top view (A). Was thinking of using a mask directly on B2, but can't since it is moving around. Confused.
Any advice?
Have you tried using the mask layer of the B's layer? Try to set it to B1 (not as a subview/sublayer) and update its position as necessary when moving B2.