Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to add a shadow to a imageview?
    text
    copied!<p>i am developing a app where i am having a imageView to add a image to it by using the image property of the imageView.but before i add a image to the imageView ,i wanted to add a shadow effect on the right side of the imageView. i found many answers in stack overflow where i was asked to call the code in drawInRect method which can be done when i draw the image on the imageView.But i am adding the image in order to give it a rich look and my images are of best quality.</p> <p>Can someone suggest me a approach.</p> <p>the end image i wanted looks like <img src="https://i.stack.imgur.com/Idywb.png" alt="this"></p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *cellIdentifier=@"identifier"; [[ListDataSource sharedDataSource] loadFiles]; ShelfCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell==nil) { cell=[[[ShelfCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier] autorelease]; } cell.backgroundColor=[UIColor greenColor]; if (indexPath.row%2==0) { cell.imageView1.image=[[ListDataSource sharedDataSource] dataAtIndex:(indexPath.row*4)+0].titleImage; cell.imageView2.image=[[ListDataSource sharedDataSource] dataAtIndex:(indexPath.row*4)+1].titleImage; cell.imageView3.image=[[ListDataSource sharedDataSource] dataAtIndex:(indexPath.row*4)+2].titleImage; cell.imageView4.image=[[ListDataSource sharedDataSource] dataAtIndex:(indexPath.row*4)+3].titleImage; cell.imageView5.image=nil; }else { cell.rackImage.frame=CGRectMake(128, bookHeight-5, 570, 60); cell.imageView1.image=nil; cell.imageView2.image=[[ListDataSource sharedDataSource] dataAtIndex:(indexPath.row*4)+0].titleImage; cell.imageView3.image=[[ListDataSource sharedDataSource] dataAtIndex:(indexPath.row*4)+1].titleImage; cell.imageView4.image=[[ListDataSource sharedDataSource] dataAtIndex:(indexPath.row*4)+2].titleImage; cell.imageView5.image=[[ListDataSource sharedDataSource] dataAtIndex:(indexPath.row*4)+3].titleImage; } return cell; } **ShelfCell.m** - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { imageView1=[[UIImageView alloc] init]; imageView1.frame=CGRectMake(10, 15, 110, 150); imageView1.layer.masksToBounds=NO; imageView1.layer.shadowRadius=5; imageView1.layer.shadowOpacity=0.5; imageView1.layer.shadowPath=[UIBezierPath bezierPathWithRect:imageView1.frame]; imageView1.layer.shadowColor = [[UIColor blackColor] CGColor]; imageView1.layer.shadowOffset = CGSizeMake(5,5); [self.contentView addSubview:imageView1]; imageView2=[[UIImageView alloc] init]; imageView2.frame=CGRectMake(CGRectGetMaxX(imageView1.frame)+30, 15, 110, 150); [self.contentView addSubview:imageView2]; imageView3=[[UIImageView alloc] init]; imageView3.frame=CGRectMake(CGRectGetMaxX(imageView2.frame)+30, 15, 110, 150); [self.contentView addSubview:imageView3]; imageView4=[[UIImageView alloc] init]; imageView4.frame=CGRectMake(CGRectGetMaxX(imageView3.frame)+30, 15, 110, 150); [self.contentView addSubview:imageView4]; imageView5=[[UIImageView alloc] init]; imageView5.frame=CGRectMake(CGRectGetMaxX(imageView4.frame)+30, 15, 110, 150); [self.contentView addSubview:imageView5]; } return self; } **ListDataSource** -(id)dataAtIndex:(NSUInteger)index{ if (index&gt;=[arrayOfDataDirectories count]) { return nil; } InfoDataSource *info = [[InfoDataSource alloc] init]; [info loadDirectoryAtPath:[arrayOfDataDirectories objectAtIndex:index]]; [info autorelease]; return info; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload