如何反转 UIView?
我正在使用 core-plot 库在我的 iPhone 应用程序上绘制条形图,当我尝试向图表添加标签或其他一些视图时出现问题,
实际上我添加的视图是垂直绘制的 invert 这样的........
代码就像
UILabel *lbl= [[UILabel alloc] initWithFrame:CGRectMake(250, 90, 70, 25)];
[lbl setBackgroundColor:[UIColor redColor]];
[lbl setText:@"HELLO"];
[self.view addSubview:lbl];
[lbl release];
我不敢玩核心图库。
那么还有其他方法可以把事情做好吗?我应该在添加视图之前进行转换吗?
如果这是解决方案,那么这将是昂贵的,因为我必须添加多个子视图。
希望大家都清楚我的问题。
I am using core-plot library to draw a bar-chart on my iPhone application and the problem arises when I try to add a label or some other views to the graph,
Actually the view I added is drawn vertically invert like this ........
The code is like
UILabel *lbl= [[UILabel alloc] initWithFrame:CGRectMake(250, 90, 70, 25)];
[lbl setBackgroundColor:[UIColor redColor]];
[lbl setText:@"HELLO"];
[self.view addSubview:lbl];
[lbl release];
I am not daring to play with core-plot library.
So is there any other way to do the things right? should I do a transform before adding the views?
If this is the solution then this will be costly because I have to add more than one subview.
Hoping my question is clear to everybody.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嗯,看起来核心图视图是使用 CGAffineTransform 反转的。您的视图可能继承了其超级视图的反转。
其实做起来很简单,
应该可以做到。
如果你必须多次执行,也许可以用诸如此类的东西来简化它
......
x轴翻转将是
CGAffineTransformMakeScale(-1,1);
Well, it looks like the core-plot view is inverted using a CGAffineTransform. Your view is probably inheriting the inversion from its superview.
It's actually quite simple to do,
Should do the trick.
If you have to do it many times perhaps simplify it with something like,
etc...
An x-axis flip would be
CGAffineTransformMakeScale(-1,1);
为了避免猜测实际的变换值,您可以尝试使用 CGAffineTransformInvert 函数:
To avoid guessing actual transform values you can try to use
CGAffineTransformInvert
function:如果我们想要转换 3D 模型层,您需要按如下方式处理它,
Swift 5:
否则您会收到这个,
If we want to transform a layer which is 3D model you need to handle it as follows,
Swift 5:
otherwise you would have receive this,