I'd like to create a view like the following.
(You may have seen similar image format in pinterest and other image sharing apps)
There will be lots of them(they will be tableview or collectionView cell).
Are there preferred way of creating the rounded effect
, shading effect
for lots of views?
Add This Framework
#import <QuartzCore/QuartzCore.h>
And use following code,
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(15, 15, self.view.bounds.size.width - 30, self.view.bounds.size.height - 30)];
view.backgroundColor = [UIColor whiteColor];
view.layer.cornerRadius = 15.f;
view.layer.borderColor = [UIColor grayColor].CGColor;
view.layer.borderWidth = 2.f;
[self.view addSubView:view];
You would need to use the CALayer
property - cornerRadius
You would require to import the QuartzCore framework to use this.
view.layer.cornerRadius = 10;
For Making views with round corners use QuartzCore framework CALayer class helps to make rounded corners, borders with color and width etc
For rounded Corners use this
[viewObject.layer setCornerRadius:15.0f];
and for Shadow use this
viewObject.layer.shadowColor = [[UIColor blackColor] CGColor];
viewObject.layer.shadowRadius = 7.0f;
viewObject.layer.shadowOpacity = 0.8f;
viewObject.layer.shadowOffset = CGSizeMake(20, 20);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.