[英]How can I add an image with coordinates in the UIView?
是否可以在 UIView 中添加具有特定坐標的圖像? 如果是這樣,任何熱衷於解釋如何做的人?
您需要創建一個 UIImageView 並將其框架設置為所需的坐標。
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:<#imageName#>]];
imageView.frame = CGRectMake(<#x#>, <#y#>, <#width#>, <#height#>);
[yourViewController.view addSubView:imageView];
讓我知道這是否適合您。
像這樣的東西?
UIImageView *myImage = [[UIImageView alloc] initWithImage:someImage];
myImage.frame = CGRectMake(40, 40, myImage.frame.size.width, myImage.frame.size.height);
[myView addSubview:myImage];
這將在特定坐標處添加包含在圖像視圖中的圖像。
是的,您必須在-(void)drawRect:(CGRect)aRect;
中繪制圖像。 ,通過UIView
,或者添加一個UIImageView
作為主視圖的子視圖,顯示圖像。
看看這些:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.