Hope you know the categories?
Creating a category would be the best option:
Command + N > Objective-C Category > Category = Animation & Category on = UIView This will create 2 files named UIView+Animation.h and UIView+Animation.m
UIView+Animation.h file
#import <UIKit/UIKit.h> #import <QuartzCore/QuartzCore.h> @interface UIView (Animation) - (void)setBackgroundShadow:(UIColor *)shadowColor CGSize:(CGSize)CGSize shadowOpacity:(float)shadowOpacity shadowRadius:(float)shadowRadius; @end
UIView+Animation.m file
#import "UIView+Animation.h" @implementation UIView (Animation) - (void)setBackgroundShadow:(UIColor *)shadowColor CGSize:(CGSize)CGSize shadowOpacity:(float)shadowOpacity shadowRadius:(float)shadowRadius { self.layer.shadowColor = shadowColor.CGColor; self.layer.shadowOffset = CGSize; self.layer.shadowOpacity = shadowOpacity; self.layer.shadowRadius = shadowRadius; self.clipsToBounds = NO; }
Import UIView+Animation.h into any of the viewController and name it as follows:
[self.titleLabel setBackgroundShadow:[UIColor grayColor] CGSize:CGSizeMake(0, 5) shadowOpacity:1 shadowRadius:5.0];
Vaibhav saran
source share