私はプロジェクトのための小さなアニメーションタイプのアプリケーションを作っています。 imageViewに画像を描画するスペースがあります。その後、新しいページボタンをクリックすると、タイムライン上にある別の画像ビューに移動するために、その画像ビュー内の画像が必要になります。あなたが必要とするその他の情報がわからない場合は、私の問題を理解していただければ幸いです。UIimageビューを他のUIimageビューと同じに設定する
0
A
答えて
1
haiこのコードをチェックすると、任意のイメージを描画することができ、次にgetimageメソッドをnsdata形式で使用してイメージにアクセスできます。その後、最初すなわち、空のUIImageViewが、起源や大きさを有する、画像と第二の任意の画像なしで、NSDataの
.h File
//
// SignatureCaptureImageView.h
// TEST_DRAW_APP
//
1. List item
// Created by Talat Masud on 8/23/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SignatureCaptureImageView : UIImageView {
CGPoint lastPoint;
BOOL mouseSwiped;
int mouseMoved;
}
-(NSData *)getImage;
@end
Implementation File
#import "SignatureCaptureImageView.h"
@implementation SignatureCaptureImageView
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
// Initialization code
self.userInteractionEnabled = YES;
mouseMoved = 0;
}
return self;
}
- (id)initWithImage:(UIImage*)image {
if ((self = [super initWithImage:image])) {
// Initialization code
self.userInteractionEnabled = YES;
mouseMoved = 0;
}
return self;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = NO;
UITouch *touch = [touches anyObject];
if ([touch tapCount] == 2)
{
//self.image = nil;
return;
}
lastPoint = [touch locationInView:self];
lastPoint.y -= 5;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
mouseSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self];
currentPoint.y -= 5;
UIGraphicsBeginImageContext(self.frame.size);
[self.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
self.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
mouseMoved++;
if (mouseMoved == 10) {
mouseMoved = 0;
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if ([touch tapCount] == 2) {
//self.image = nil;
return;
}
if(!mouseSwiped) {
UIGraphicsBeginImageContext(self.frame.size);
[self.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
self.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
}
-(NSData *)getImage{
return UIImagePNGRepresentation(self.image);
}
- (void)dealloc {
[super dealloc];
}
@end
0
宣言2つのUIImageViewsから画像に変換することができます。その後
、uはアニメーション、次の操作を行い、
[UIView animateWithDuration:3.0
animations:^{
CGRect sframe = mSecondImgView.frame;
mFirstImgView.frame = sframe;
}
completion:^(BOOL finished){
}];
関連する問題
- 1. uipickerビューの整数とuiimage
- 2. uiimageビューと長方形
- 3. 新しいビューのUIImageを設定して表示する
- 4. UIImageビューへのアニメーション(objective-c)
- 5. 他のビューと同じ幅のビューの幅を変更する
- 6. 他のUIImageとUIImageの一部を消去する方法
- 7. UIImageの高さを幅と同じに設定してください。
- 8. UIImageフレームの設定方法
- 9. 別のUIImageビューでUIImageViewでユーザーインタラクションを有効にする
- 10. UIImageビューをNSURLに変換してFirebaseにアップロードする
- 11. クロップUIImageビューを親の境界に合わせる
- 12. cellForRowAtIndexPathからUIImageビューのサブクラスにプロパティを渡す方法
- 13. programatically uiimageのvisibiltyを設定します
- 14. 私は特定のテーブルのセルからIBOutlet UIimageを削除するカスタムuitablecellビュー
- 15. 同じパスにUIImageを再保存する方法
- 16. 他のテキストと一緒にFacebookにUIImageを投稿する
- 17. マルチビューと同じビューのボタン
- 18. テーブルとビューの同じエンティティクラス
- 19. UIImageとのディープリンク
- 20. 編集したUIImageの変更を同じファイルに保存
- 21. UIImage
- 22. UIImage
- 23. 同じビューのMultipleGesture
- 24. autolayoutビジュアルフォーマット言語を使用すると、ビューの幅を同じビューの高さと同じに設定できますか?
- 25. ピンチとズームUIImage
- 26. アプリケーショングループとUIImage Swift
- 27. UIImageフリップとミラー
- 28. UIImageアニメーションを適切に設定する方法は?
- 29. タグに基づいてUIImageを設定する
- 30. 同じWebビューで次のデータを読み込んでいる最上部のWebビューに設定します。
したいのでimageviews両方が右、同じビューにありますか? – Ilanchezhian