Hello and Greetings.
I am trying to develop a rating analyzer application. I have placed a
UIImageView, a slider control, and a simple button on a screen. My logic is
that as the user slides the slider control either up or down and then click
on the button, the UIImageView will render a horizontal bar which will be
partially filled with some color [obviously there will be a base color and a
top color for this bar] depending on the value of the slider. I have
developed some code, after doing a hell of a lot of googling gathering
resources from here and there, but as it stands I am not getting any output.
The bar is not getting created. The image view is totally blank. I am
totally new to IOS App Development. In .Net I have scarcely used GDI+, so my
foundations are not that strong. Please help me rectify the situation by
spotting the errors in my code block. I really need some active help on this
one. Here are the code blocks that I am using :
The code that is supposed to create the image object-->
private UIImage makeProgressImage (int width, int height, float progress,
CGColor baseColor, CGColor topColor)
{
CGBitmapContext ctx = new CGBitmapContext (IntPtr.Zero,
width, height, 8,
4 * width, CGColorSpace.CreateDeviceRGB (),
CGImageAlphaInfo.PremultipliedFirst);
ctx.SetFillColor(baseColor);
ctx.FillRect (new RectangleF (0, 0, width, height));
float percentWidth = width * progress;
ctx.SetFillColor(topColor);
ctx.FillRect (new RectangleF (0, 0, percentWidth,
height));
return UIImage.FromImage (ctx.ToImage ());
}
The functions that are presetting the base color and top colors for the bar
->
private CGColor getTopColor ()
{
return new CGColor (10, 12, 25);
}
private CGColor getBaseColor ()
{
return new CGColor (20, 24, 50);
}
Finally the function call in my Button click event -->
partial void basicTouch (MonoTouch.UIKit.UIButton sender)
{
image.Image = makeProgressImage
((int)image.Bounds.Width - 20, 30,
percentage.Value, getBaseColor (), getTopColor ());
}
See the screen shot for easier understanding:
http://monotouch.2284126.n4.nabble.com/file/n4655957/shot.png
In the blank space there's supposed to be the horizontal bar rendered, where
I have placed my UIImageView control.
Please help me.
Many Thanks.
--
View this message in context:
http://monotouch.2284126.n4.nabble.com/Create-a-Custom-Rating-Analyzer-Bar-with-CoreGraphics-Help-Needed-Urgently-tp4655957.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch