Popular Posts

There was an error in this gadget

Jul 27, 2011

Find Color From Hex Code


In i phone you can find the color using the color code. which is in hex form.
Say a color Almond which code is #EED9C4.
how you can find the color...Try to understand the code below...

// Convert a 6-character hex color to a UIColor object
- (UIColor *) getColor: (NSString *) hexColor
{
         unsigned int red, green, blue;
         NSRange range;
         range.length = 2;
        
         range.location = 0;
         [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&red];
         range.location = 2;
         [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&green];
         range.location = 4;
         [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&blue];
        
         return [UIColor colorWithRed:(float)(red/255.0f) green:(float)(green/255.0f) blue:(float)(blue/255.0f) alpha:1.0f];
}

//Call the method  
[self getColorEED9C4];



Jul 21, 2011

Struct(C#)


struct type is a value type that can contain constructors, constants, fields, methods, properties, indexers, operators, events, and nested types.
The format of declaration of struct is :
[attributes] [modifiers] struct identifier [:interfaces] body [;]


attributes (Optional)

Additional declarative information. For more information on attributes and attribute classes

modifiers (Optional)

The allowed modifiers are new and the four access modifiers.

identifier

The struct name.

interfaces (Optional)

A list that contains the interfaces implemented by the struct, all separated by commas.

body

The struct body that contains member declarations.

For more visit:
http://msdn.microsoft.com/en-us/library/ah19swz4(v=vs.71).aspx