Added Copy and fixed paste bug. Added selected state for BubbleView. may need a little work on the artwork.

This commit is contained in:
Kyle Fang
2013-07-25 23:00:01 +08:00
parent c3ceb006b4
commit 2ccfd5ffdb
7 changed files with 42 additions and 7 deletions

View File

@@ -177,7 +177,7 @@
return;
UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setTargetRect:self.bubbleView.frame inView:self];
[menu setTargetRect:CGRectInset([self.bubbleView bubbleFrame], 0, 4.f) inView:self];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(menuWillShow:)
@@ -201,6 +201,7 @@
- (void) menuWillHide:(NSNotification *)notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIMenuControllerWillHideMenuNotification object:nil];
self.bubbleView.selectedToShowCopyMenu = NO;
}
- (void) menuWillShow:(NSNotification *)notification
@@ -210,6 +211,7 @@
selector:@selector(menuWillHide:)
name:UIMenuControllerWillHideMenuNotification
object:nil];
self.bubbleView.selectedToShowCopyMenu = YES;
}
- (void)dealloc{

View File

@@ -40,7 +40,7 @@ typedef enum {
JSBubbleMessageStyleIncomingSquare,
JSBubbleMessageStyleOutgoingDefault,
JSBubbleMessageStyleOutgoingDefaultGreen,
JSBubbleMessageStyleOutgoingSquare
JSBubbleMessageStyleOutgoingSquare,
} JSBubbleMessageStyle;
@@ -53,6 +53,9 @@ typedef enum {
#pragma mark - Initialization
- (id)initWithFrame:(CGRect)frame bubbleStyle:(JSBubbleMessageStyle)bubbleStyle;
- (CGRect)bubbleFrame;
@property (nonatomic) BOOL selectedToShowCopyMenu;
#pragma mark - Bubble view
+ (UIImage *)bubbleImageForStyle:(JSBubbleMessageStyle)style;
+ (UIFont *)font;

View File

@@ -86,16 +86,36 @@
[self setNeedsDisplay];
}
- (void)setSelectedToShowCopyMenu:(BOOL)selectedToShowCopyMenu{
_selectedToShowCopyMenu = selectedToShowCopyMenu;
[self setNeedsDisplay];
}
#pragma mark - Drawing
- (void)drawRect:(CGRect)frame
{
UIImage *image = [JSBubbleView bubbleImageForStyle:self.style];
- (CGRect)bubbleFrame{
CGSize bubbleSize = [JSBubbleView bubbleSizeForText:self.text];
CGRect bubbleFrame = CGRectMake(([self styleIsOutgoing] ? self.frame.size.width - bubbleSize.width : 0.0f),
kMarginTop,
bubbleSize.width,
bubbleSize.height);
return bubbleFrame;
}
- (void)drawRect:(CGRect)frame
{
UIImage *image = nil;
if (self.selectedToShowCopyMenu) {
if ([self styleIsOutgoing]) {
image = [[UIImage imageNamed:@"messageBubbleHighlighted"] stretchableImageWithLeftCapWidth:15 topCapHeight:15];
} else {
image = [[UIImage imageNamed:@"messageBubbleSelected"] stretchableImageWithLeftCapWidth:23 topCapHeight:15];
}
} else {
image = [JSBubbleView bubbleImageForStyle:self.style];
}
[JSBubbleView bubbleImageForStyle:self.style];
CGRect bubbleFrame = [self bubbleFrame];
[image drawInRect:bubbleFrame];
CGSize textSize = [JSBubbleView textSizeForText:self.text];

View File

@@ -271,7 +271,9 @@
BOOL isShrinking = textViewContentHeight < self.previousTextViewContentHeight;
CGFloat changeInHeight = textViewContentHeight - self.previousTextViewContentHeight;
changeInHeight = (textViewContentHeight + changeInHeight >= maxHeight) ? 0.0f : changeInHeight;
if (changeInHeight > 0 && self.previousTextViewContentHeight == maxHeight) {
changeInHeight = 0;
}
if(!isShrinking)
[self.inputToolBarView adjustTextViewHeightBy:changeInHeight];

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
049A2A3717A16EA0000D4811 /* messageBubbleSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = 049A2A3517A16E9E000D4811 /* messageBubbleSelected.png */; };
049A2A3817A16EA0000D4811 /* messageBubbleSelected@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 049A2A3617A16E9F000D4811 /* messageBubbleSelected@2x.png */; };
881AE55D16D13CDC008F7636 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 881AE55C16D13CDC008F7636 /* UIKit.framework */; };
881AE55F16D13CDC008F7636 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 881AE55E16D13CDC008F7636 /* Foundation.framework */; };
881AE56116D13CDC008F7636 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 881AE56016D13CDC008F7636 /* CoreGraphics.framework */; };
@@ -54,6 +56,8 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
049A2A3517A16E9E000D4811 /* messageBubbleSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = messageBubbleSelected.png; sourceTree = "<group>"; };
049A2A3617A16E9F000D4811 /* messageBubbleSelected@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "messageBubbleSelected@2x.png"; sourceTree = "<group>"; };
881AE55916D13CDC008F7636 /* MessagesDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MessagesDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
881AE55C16D13CDC008F7636 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
881AE55E16D13CDC008F7636 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -222,6 +226,8 @@
88301EF216F77B3D0037524D /* Images */ = {
isa = PBXGroup;
children = (
049A2A3517A16E9E000D4811 /* messageBubbleSelected.png */,
049A2A3617A16E9F000D4811 /* messageBubbleSelected@2x.png */,
88244C0116FE5BA300034667 /* bubbleSquareIncoming.png */,
88244C0216FE5BA300034667 /* bubbleSquareIncoming@2x.png */,
88244C0316FE5BA300034667 /* bubbleSquareOutgoing.png */,
@@ -337,6 +343,8 @@
88244C0616FE5BA400034667 /* bubbleSquareIncoming@2x.png in Resources */,
88244C0716FE5BA400034667 /* bubbleSquareOutgoing.png in Resources */,
88244C0816FE5BA400034667 /* bubbleSquareOutgoing@2x.png in Resources */,
049A2A3717A16EA0000D4811 /* messageBubbleSelected.png in Resources */,
049A2A3817A16EA0000D4811 /* messageBubbleSelected@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};