objective-c - 当我设置 anchor 时,我的图像没有加载

标签 objective-c ios ipad core-graphics

我有一个 UIView,我正在将我的 ImageView 加载为 subview 。当我没有设置 anchor 时图像显示,但每当我设置 anchor 时图像不显示。我还添加了 QUARTZCore 框架。

我在下面添加我的代码

CGRect apprect=CGRectMake(0, 0, 1024, 768);
UIView *containerView = [[UIView alloc] initWithFrame:apprect1];
containerView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:containerView];

handleView1= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"large.gif"]];
[handleView1 setAlpha:1];
//[handleView1 setFrame:CGRectMake(390, 172.00, 56.00, 316.00)];
handleView1.userInteractionEnabled = YES;
handleView1.layer.anchorPoint=CGPointMake(490.0, 172.0);
[containerView addSubview:handleView1];

最佳答案

问题是您用于 anchor 的值。您不会将框架位置之类的点设置为值。让我引用苹果的话:

The anchorPoint property is a CGPoint that specifies a location within the bounds of a layer that corresponds with the position coordinate. The anchor point specifies how the bounds are positioned relative to the position property, as well as serving as the point that transforms are applied around. It is expressed in the unit coordinate system-the (0.0,0.0) value is located closest to the layer’s origin and (1.0,1.0) is located in the opposite corner.

enter image description here

看看Layer Geometry and Transforms in the Core Animation Programming Guide了解更多详情。

关于objective-c - 当我设置 anchor 时,我的图像没有加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5960697/

相关文章:

objective-c - 获取具有特定属性的 NSManagedObject

iphone - _OBJC_CLASS_$_ - 找不到符号错误

ios - 使用@ gmail.com和数字自定义uikeyboardtype

java - macOS "Big Sur"检测深色菜单栏/系统托盘

ios - iPhone:启用蜂窝 radio 的 IPv4 Wi-Fi 访问失败

ios - 什么会阻止我的用户接收短信?

ios - 上个月的同一天 ios

iphone - iOS 应用程序是否可提取?

javascript - 键盘使用后 iPad css3 动画闪烁

iphone - IB、UITableView 分组样式设置不生效