How to give shadow like card in iOS

Maybe someone needs Swift version

func setCardView(view : UIView){

        view.layer.masksToBounds = false
        view.layer.shadowOffset = CGSizeMake(0, 0);
        view.layer.cornerRadius = 1; 
        view.layer.shadowRadius = 1;
        view.layer.shadowOpacity = 0.5;

    }

An improvised solution on swift 3.0:

extension UIView {

    func setCardView(){
        layer.cornerRadius = 5.0
        layer.borderColor  =  UIColor.clear.cgColor
        layer.borderWidth = 5.0
        layer.shadowOpacity = 0.5
        layer.shadowColor =  UIColor.lightGray.cgColor
        layer.shadowRadius = 5.0
        layer.shadowOffset = CGSize(width:5, height: 5)
        layer.masksToBounds = true
    }
}

Usage:

On cellForRowAt indexPath:

var cell = UITableViewCell()

cell.contentView.setCardView()

Use a container view inside your table view cell and assign tag say 99. Keep the cell height a bit larger then your card (container view).

and give shadow to your card view

UIView* shadowView = [cell viewWithTag:99];
shadowView.backgroundColor=[UIColor colorWithRed:228.0/255.0 green:228.0/255.0 blue:228.0/255.0 alpha:0.5];
[shadowView.layer setCornerRadius:5.0f];
[shadowView.layer setBorderColor:[UIColor lightGrayColor].CGColor];
[shadowView.layer setBorderWidth:0.2f];
[shadowView.layer setShadowColor:[UIColor colorWithRed:225.0/255.0 green:228.0/255.0 blue:228.0/255.0 alpha:1.0].CGColor];
[shadowView.layer setShadowOpacity:1.0];
[shadowView.layer setShadowRadius:5.0];
[shadowView.layer setShadowOffset:CGSizeMake(5.0f, 5.0f)];