25
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UIView(とそれを継承したView)に影をつけたい時

Posted at

CALayerを使うことで、ビューに影をつけることが出来ます。
各プロパティの値を変えると、描画される影が変化します。

CALayerSample

- (void)shadowSample{
    UIView *uiView = [[UIView alloc] initWithFrame:CGRectMake(110, 200, 100, 100)];
    uiView.backgroundColor = [UIColor whiteColor];
    CALayer *caLayer = uiView.layer;
    caLayer.rasterizationScale = [[UIScreen mainScreen] scale];
    caLayer.shadowRadius = 3.0f;
    caLayer.shadowOpacity = 1.5f;
    caLayer.shadowOffset = CGSizeMake(0.0f, 1.0f);
    caLayer.shouldRasterize = YES;
    [self.view addSubview:uiView];
}

影をつけない場合             影をつけた場合

影無し 影有り

25
25
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?