Customize UINavigationBar gradient color in ObjectIveC

Hi friends,
Good day!

I am going to share customize gradient effect in UINavigationBar.

Add this source code to (yourClass.h)
Example: (Do like this)
@interface yourclassname: UIViewController
{
}

#define UIColorFromRGB(rgbValue) [UIColor \
|colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

//RGB color macro with alpha
#define UIColorFromRGBWithAlpha(rgbValue,a) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:a]

@end

Then where you want to add gradient effect like this inside (YourClass.m)

- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.tintColor = UIColorFromRGB(0xD2691E);
// (UIColorFromRGB) use this keyWord to set your RGB value.
}
Thats it, tried this to make your own UINavigationBar style.
I hope to help any one.

Thanks
Sampath
Team Lead
Everest Software solution

 

Set Gradient effect in UITableviewCell in iPhone

Hi Friends

Good day!

Already i have post Using  CAGradientLayer to set background View and the same concept but it used in UITableviewCell.
– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @”Cell”;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.backgroundColor = [UIColor clearColor];
CAGradientLayer *grad = [CAGradientLayer layer];
grad.frame = CGRectMake(0, 0, 300, 30);
grad.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor] CGColor], (id)[[UIColor clearColor] CGColor], nil];
[cell setBackgroundView:[[UIView alloc] init]];
[cell.backgroundView.layer insertSublayer:grad atIndex:0];
CAGradientLayer *selectedGrad = [CAGradientLayer layer];
selectedGrad.frame = CGRectMake(0, 0, 300, 30);
selectedGrad.colors = [NSArray arrayWithObjects:(id)[[UIColor clearColor] CGColor], (id)[[UIColor purpleColor] CGColor], nil];
[cell setSelectedBackgroundView:[[UIView alloc] init]];
[cell.selectedBackgroundView.layer insertSublayer:selectedGrad atIndex:0];
}

I hope to help anyone
Thanks
Sampathkumar

Gradient effect in Background view in iPHONE

Hi Friends

Good Day!

Using CAGradientLayer to set gradient effect in background view

 CAGradientLayer *grad = [CAGradientLayer layer];

grad.frame = CGRectMake(0, 0, 1024, 768);

grad.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor] CGColor], (id)[[UIColor clearColor] CGColor], nil];

[self.view.layer addSublayer:grad];

You have to change your own color to set it.

 

I hope to help any one

Thanks

MinuSampathKumar

Link

Store pdf file from URL

Hi friends,

 

Here i have mentioned store pdf file from URL

 

 NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@”http://www.msy.com.au/Parts/PARTS.pdf”%5D%5D;

  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 

    NSString *documentsDirectory = [paths objectAtIndex:0]; 

    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@”myPDF11.pdf”];

    NSLog(@”filePath:%@”,filePath);

    [pdfData writeToFile:filePath atomically:YES];

 

Thanks