This example shares the specific code of IOS to realize the reflection effect for your reference. The specific contents are as follows
1、 Brief description
We can duplicate layers, create a duplicate layer, and then rotate it to add the corresponding color difference. The effect can be achieved
When creating the interface, our view uses vcview
2、 Code
2.1 VCView.m
//
// VCView.m
// 03_ UIView76_ inverted reflection in water
//
//Created by Qiwen on 17 / 7 / 22
// Copyright © 2017 qiwenming All rights reserved.
//
#import "VCView.h"
@implementation VCView
+(Class)layerClass{
return [CAReplicatorLayer class];
}
@end
2.2 ViewController.m
//
// ViewController.m
// 03_ UIView76_ inverted reflection in water
//
//Created by Qiwen on 17 / 7 / 22
// Copyright © 2017 qiwenming All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//Get the copy layer and copy the sub layer (the view here is vcview)
CAReplicatorLayer * repL = (CAReplicatorLayer*)self.view.layer;
repL.instanceCount = 2;
//Rotate 180 degrees PI about the X axis
repL.instanceTransform = CATransform3DMakeRotation(M_PI, 1, 0, 0);
repL.instanceRedOffset -= 0.1;
repL.instanceGreenOffset -= 0.1;
repL.instanceBlueOffset -=0.1;
repL.instanceAlphaOffset -= 0.1;
}
@end
3、 Illustration
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support developpaer.