How do I create shadow of CPBarPlot? - iphone

I want to create shadow of barplot what should I do . I use core-plot framwork

I dont know abt giving exactly shadow effect on individual bar. But similar to shadow effect, You can try using 'tubular' bar rather than flat bars. +(CPBarPlot *)tubularBarPlotWithColor:(CPColor *)color horizontalBars:(BOOL)horizontal
something like this
barPlot = [CPBarPlot tubularBarPlotWithColor:[CPColor greenColor] horizontalBars:NO];
[barGraph addPlot:barPlot toPlotSpace:barPlotSpace];
Hope this helps.

Related

How to remove rounded corner background on UITableView group style when cell is selected?

I'm using a UITableView with group style. I made some specific changes and the normal view of the cell no longer has the rounded corners on grouping. I would like to remove this and just use the plain style of selection. I tried setting selectedBackgroundView to nil for the cell returned by -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath, but it doesn't change anything. Is there something else I must set to get this behavior?
As a side note, I do have to use group style and I know its weird that I basically want it to act like a plain style table on selection, but there are certain behaviors inherent to group style tables that I wanted, just not the look.
Instead of setting selectedBackgroundView to nil, I actually added an actual UIView. This seems to work in replacing it. Now I just need to find out how to make it look like the plain one, but this has at least solved my initial problem.
#import <QuartzCore/QuartzCore.h>
then use
CALayer * layer = [table layer];
[layer setMasksToBounds:YES];
[layer setCornerRadius:0.0]; //note that when radius is 0, the border is a rectangle
[layer setBorderWidth:3.0];
[layer setBorderColor:[[UIColor whiteColor] CGColor]];

Plotting border dissapears when changing FaceAlpha

I'm trying to change the FaceAlpha (make transparent) of my bar plot. If I do like this the right border of the plot dissapears. This is what it looks like of I don't change the FaceAlpha:
barplot = bar(xmin:binw:xmax,prob);
And if I try to change it, like this:
barplot = bar(xmin:binw:xmax,prob);
set(get(barplot,'Child'),'FaceAlpha',0.3)
The right border dissapears!
Furhtermore, what I really want is to make a bar plot with the 'hist' option. But then it doesn't work to change the FaceAlpha! Like this:
barplot = bar(xmin:binw:xmax,prob,'hist');
set(get(barplot,'Child'),'FaceAlpha',0.3) //This row has no effect
Any ideas why this doesn't work?
Thank you in advance!
Found a solution to the dissapearing border here, and it works:
http://www.mathworks.se/support/solutions/en/data/1-5X41G7/index.html
Still the question remains why it's not possible to change the FaceAlpha when using the 'hist' option.

Shadow to a label

I need to add shadow to all side to a label.It will look like this.
How Can I do this?Please help.I am using shadowOffset ,but it is not giving shadow in all side.Please help.
Assuming you're asking how to add the white outline, you can't do that with a plain UILabel. You need to draw the text using Core Graphics (aka Quartz 2D). Something like this:
CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextSaveGState(gc); {
CGContextSetTextDrawingMode(gc, kCGTextFillStroke);
CGContextSetFillColorWithColor(gc, UIColor.blueColor.CGColor);
CGContextSetStrokeColorWithColor(gc, UIColor.whiteColor.CGColor);
CGContextSetLineJoin(gc, kCGLineJoinRound);
CGContextSetLineWidth(gc, 2);
CGContextSetShadowWithColor(gc, CGSizeMake(-1, 2), 2, UIColor.blackColor.CGColor);
[#"Card" drawAtPoint:CGPointMake(0, 20) withFont:[UIFont systemFontOfSize:18]];
} CGContextRestoreGState(gc);
I have come across a project by nicklockwood on gitHub. It improves upon the standard UILabel by providing a subclass that supports soft shadows, inner shadow and gradient fill, and which can easily be used in place of any standard UILabel.Have a look at it.It will be useful to you.

Composite Chart + Objective C

I want to implement below chart like structure.
Explanation:
1. Each block should be clickable.
2. If the block is selected, it will be highlighted(i.e. Red block in figure).
I initially google for this but was unable to find. What should be "Drawing logic" corresponding to this with animation?Thanx in advance.
I think you need to use MCSegmentedControl.
You can get it from here.
Generally speaking, I'd have an image for the outline with a transparent middle, then dynamically create colored blocks behind it of the appropriate colors, with dynamic labels. The highlighting is a little tricky, but could be done with a set of image overlays. One could also try to shrink and expand fixed images for the bars/highlighting, but iPhone scales images poorly.
(Will it always be 4 blocks? There are a couple of other ways to manage it using fixed-size images overlaying each other.)
Maybe you should look into using CALayer for this?
U need to implement this type of logic using button. Just scale button width according to percentage.
And to make round rect button like appearance use the code below and don't forget to import quartz-core framework in class file.
And to scale first and last button as you need some overlap from nearby button.
btn.layer.cornerRadius = 8.0;
btn.layer.borderWidth = 0.5;
btn.layer.borderColor = [[UIColor blackColor] CGColor];

Inner shadow in a UILabel

What's the easiest way to draw an inner shadow in a UILabel, without using images?
I know you can use shadowColor and shadowOffset for drop shadows, but I didn't see any such properties for inner shadows.
Check out FXLabel. I've been using it recently and it works great.
https://github.com/nicklockwood/FXLabel
I do not believe there is any easy way to accomplish this appearance. You will either need to use an image or a custom view that draws the shadow.
I would use your favorite image editor to make an image of the inner shadow composited against transparency (or a color if you need it) and load it into a stretchable UIImage. For example here is an inner shadow image (17px x 17px):
You can load it like this:
UIImage* innerShadow = [ [ UIImage imageNamed: "innershadow.png" ]
stretchableImageWithLeftCapWidth: 8 topCapHeight: 8 ];
UIImageView* innerShadowView = [ [ [ UIImageView alloc ] initWithImage: innerShadow ]
autorelease ];
myLabel.backgroundColor = [ UIColor clearColor ];
Then place innerShadowView behind the label. You could generate the image programmatically as well if you wanted to avoid an image resource.
** Update based on comments follows **
Ah, based on your latest comment the effect you are looking for is completely different than the picture in the earlier comment.
In this case you will have to make a UILabel subclass and do your own drawing to composite the effect you are looking for. Take a look at this answer for how to composite the inner shadow effect.
What you mean by any such properties for inner shadows.
shadowOffset is the option to set the shadows (vertical or horizontal shadow) of the UILabel.
I do not know but this answer may be long to implement.