سؤال

في أحد رأيي، أضيف الظل إلى طريقة عرض.الشيء هو أن الظل يظهر المساحات البيضاء على الحواف اليسرى واليمين.أريد إزالة هذه المسافات.

هنا هو رمزي: giveacodicetagpre.

هنا هو رأيي O / P:

أدخل وصف الصورة هنا

هل كانت مفيدة؟

المحلول

If you want homogenous shadow without side effects you can draw it in graphics editor, save to png and place UIImageView with stretchable image on your view. And don't forget to set clipToBounds to NO.

UIView *myView = [[ISTView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 35)];
myView.backgroundColor = [UIColor greyColor];
myView.clipToBounds = NO;

UIImageView *shadowView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 35, 320, 10)];
shadowView.image = [UIImage imageWithName:@"my-shadow.png"];
[myView addSubview:shadowView];
[shadowView release];

[self.view addSubview:myView];
[myView release];

It would be cheaper for system to draw cached existing image above view hierarcy than calculate layer's shadow.

نصائح أخرى

Use shadowPath to make the shadow larger then the view

view.layer.shadowPath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, view.frame.size.width+30, view.frame.size.height)].CGPath;

One solution I could think of and is working also is to adjust the view's frame by 2 pixels in X position and width:

UIView *myView = [[ISTView alloc] initWithFrame:CGRectMake(-2.0, 0.0, 324.0, 35)];

But this is not a cleaner approach of doing this. If anyone has better solution, please guide.

Try this, remove the code: [myView.layer setShadowRadius:2.0];

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top