我已经在这里以及Apple文档中找到了最佳方法,并找到了获得中心坐标的CGRectGetMIDY和CGRectGetMIDX.
当我尝试将此实现到我自己的代码中时,我遇到了问题.我在UIIMageVIEw类型的对象上找不到属性大小错误
#import "MyVIEwController.h" @interface MyVIEwController () @end @implementation MyVIEwController @synthesize mySignatureImage; @synthesize lastContactPoint1,lastContactPoint2,currentPoint; @synthesize imageFrame; @synthesize fingerMoved; @synthesize navbarHeight; - (ID)initWithNibname:(Nsstring *)nibnameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibname:nibnameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (voID)vIEwDIDLoad { [super vIEwDIDLoad]; self.vIEw.backgroundcolor = [UIcolor lightGraycolor]; CGRect mySignatureImageFrame = CGRectMake( CGRectGetMIDX(self.vIEw.frame) - (mySignatureImage.size.wIDth/ 2.0),CGRectGetMIDY(self.vIEw.frame) - (mySignatureImage.size.height / 2.0),image.size.wIDth,image.size.height);#import <UIKit/UIKit.h>@interface MyVIEwController : UIVIEwController <UIAlertVIEwDelegate>@property (nonatomic,strong) UIImageVIEw *mySignatureImage;@property (nonatomic,assign) CGPoint lastContactPoint1,currentPoint;@property (nonatomic,assign) CGRect imageFrame;@property (nonatomic,assign) BOol fingerMoved;@property (nonatomic,assign) float navbarHeight;@property (strong,nonatomic) NSManagedobjectContext *managedobjectContext;解决方法 假设图像是UIImage类型,那么:
CGRect imageFrame = CGRectMake( CGRectGetMIDX(self.vIEw.frame) - (image.size.wIDth / 2.0),CGRectGetMIDY(self.vIEw.frame) - (image.size.height / 2.0),image.size.height);
假设imageVIEw的类型为UIImageVIEw,则:
CGRect imageFrame = CGRectMake( CGRectGetMIDX(self.vIEw.frame) - CGRectGetMIDX(imageVIEw.frame),CGRectGetMIDY(self.vIEw.frame) - CGRectGetMIDY(imageVIEw.frame),CGRectGetWIDth(imageVIEw.frame),CGRectGetHeight(imageVIEw.frame));总结
以上是内存溢出为你收集整理的ios – Ipad的CGRect中心全部内容,希望文章能够帮你解决ios – Ipad的CGRect中心所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)