-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
简单的文本选择
- Loading branch information
Tigerwf
authored and
Tigerwf
committed
Jan 29, 2015
1 parent
349f1d0
commit f9d850c
Showing
9 changed files
with
541 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// E_CursorView.h | ||
// WFReader | ||
// | ||
// Created by 阿虎 on 15/1/29. | ||
// Copyright (c) 2015年 tigerwf. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
/** | ||
* 光标类 | ||
*/ | ||
|
||
typedef enum { | ||
CursorLeft = 0, | ||
CursorRight , | ||
|
||
} CursorType; | ||
|
||
@interface E_CursorView : UIView | ||
{ | ||
UIImageView *_dragDot; | ||
} | ||
@property (nonatomic,assign) CursorType direction; | ||
@property (nonatomic,assign) float cursorHeight; | ||
@property (nonatomic,retain) UIColor *cursorColor; | ||
@property (nonatomic,assign) CGPoint setupPoint; | ||
|
||
- (id)initWithType:(CursorType)type andHeight:(float)cursorHeight byDrawColor:(UIColor *)drawColor; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// E_CursorView.m | ||
// WFReader | ||
// | ||
// Created by 阿虎 on 15/1/29. | ||
// Copyright (c) 2015年 tigerwf. All rights reserved. | ||
// | ||
|
||
#import "E_CursorView.h" | ||
#define kE_CursorWidth 2 | ||
|
||
@implementation E_CursorView | ||
|
||
/* | ||
// Only override drawRect: if you perform custom drawing. | ||
// An empty implementation adversely affects performance during animation. | ||
- (void)drawRect:(CGRect)rect { | ||
// Drawing code | ||
} | ||
*/ | ||
|
||
- (id)initWithType:(CursorType)type andHeight:(float)cursorHeight byDrawColor:(UIColor *)drawColor{ | ||
self = [super init]; | ||
if (self) { | ||
_direction = type; | ||
_cursorHeight = cursorHeight; | ||
_cursorColor = drawColor; | ||
self.clipsToBounds = NO; | ||
|
||
} | ||
return self; | ||
|
||
} | ||
|
||
|
||
- (void)setSetupPoint:(CGPoint)setupPoint{ | ||
|
||
self.backgroundColor = _cursorColor; | ||
|
||
if (_dragDot) { | ||
[_dragDot removeFromSuperview]; | ||
_dragDot = nil; | ||
} | ||
|
||
_dragDot = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"r_drag-dot.png"]]; | ||
|
||
if (_direction == CursorLeft) { | ||
self.frame = CGRectMake(setupPoint.x - kE_CursorWidth, setupPoint.y - _cursorHeight, kE_CursorWidth, _cursorHeight); | ||
_dragDot.frame = CGRectMake(-7, -8, 15, 17); | ||
|
||
}else{ | ||
self.frame = CGRectMake(setupPoint.x, setupPoint.y - _cursorHeight, kE_CursorWidth, _cursorHeight); | ||
_dragDot.frame = CGRectMake(-6, _cursorHeight - 8, 15, 17); | ||
} | ||
[self addSubview:_dragDot]; | ||
} | ||
|
||
- (void)dealloc{ | ||
|
||
|
||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// E_MagnifiterView.h | ||
// WFReader | ||
// | ||
// Created by 阿虎 on 15/1/29. | ||
// Copyright (c) 2015年 tigerwf. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
/** | ||
* 放大镜类 | ||
*/ | ||
@interface E_MagnifiterView : UIView | ||
|
||
@property (weak, nonatomic) UIView *viewToMagnify; | ||
@property (nonatomic) CGPoint touchPoint; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// E_MagnifiterView.m | ||
// WFReader | ||
// | ||
// Created by 阿虎 on 15/1/29. | ||
// Copyright (c) 2015年 tigerwf. All rights reserved. | ||
// | ||
|
||
#import "E_MagnifiterView.h" | ||
|
||
@implementation E_MagnifiterView | ||
|
||
- (id)initWithFrame:(CGRect)frame { | ||
|
||
if (self = [super initWithFrame:CGRectMake(0, 0, 80, 80)]) { | ||
self.layer.borderColor = [[UIColor lightGrayColor] CGColor]; | ||
self.layer.borderWidth = 1; | ||
self.layer.cornerRadius = 40; | ||
self.layer.masksToBounds = YES; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)setTouchPoint:(CGPoint)touchPoint { | ||
|
||
_touchPoint = touchPoint; | ||
self.center = CGPointMake(touchPoint.x, touchPoint.y - 70); | ||
[self setNeedsDisplay]; | ||
} | ||
|
||
- (void)drawRect:(CGRect)rect { | ||
|
||
CGContextRef context = UIGraphicsGetCurrentContext(); | ||
CGContextTranslateCTM(context, self.frame.size.width * 0.5,self.frame.size.height * 0.5); | ||
CGContextScaleCTM(context, 1.5, 1.5); | ||
CGContextTranslateCTM(context, -1 * (_touchPoint.x), -1 * (_touchPoint.y)); | ||
[self.viewToMagnify.layer renderInContext:context]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.