TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jan 2016 |
Maintained by Jesse Squires.
A messages UI for iPhone and iPad.
JSMessagesViewController
is a UIViewController
subclass that is very similar to the iOS Messages app.
See more screenshots in the Screenshots/
directory.
JSMessagesViewController/
folder to your projectQuartzCore.framework
to your project-fobjc-arc
compiler flag to all source files in your project in Target Settings > Build Phases > Compile Sources.Your model objects should conform to the JSMessageData
protocol. However, you may use the provided JSMessage
class for your model objects if you wish.
JSMessagesViewController
<JSMessagesViewDelegate, JSMessagesViewDataSource>
JSMessagesViewDelegate
protocolJSMessagesViewDataSource
protocoltableView: numberOfRowsInSection:
from the UITableViewDataSource
protocol.viewDidLoad
like the following:- (void)viewDidLoad
{
self.delegate = self;
self.dataSource = self;
[super viewDidLoad];
[[JSBubbleView appearance] setFont:/* your font for the message bubbles */];
self.title = @"Your view controller title";
self.messageInputView.textView.placeHolder = @"Your placeholder text";
self.sender = @"Username of sender";
}
Present your subclassed view controller programatically or via StoryBoards. Your subclass should be the rootViewController
of a UINavigationController
, or pushed on an existing navigation stack.
You may want to show the most recent message when presenting your view: (this is no longer default behavior)
// Scroll to the most recent message before view appears
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self scrollToBottomAnimated:NO];
}
JSMessagesDemo.xcworkspace
. Don't forget to run pod install
before opening!Documentation is available here via CocoaDocs. Thanks @CocoaDocs!
Support the developement of this free, open-source control! via Square Cash.
configureCell: atIndexPath:
- (void)configureCell:(JSBubbleMessageCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
if ([cell messageType] == JSBubbleMessageTypeOutgoing) {
// Customize any UITextView properties
cell.bubbleView.textView.textColor = [UIColor whiteColor];
if ([cell.bubbleView.textView respondsToSelector:@selector(linkTextAttributes)]) {
NSMutableDictionary *attrs = [cell.bubbleView.textView.linkTextAttributes mutableCopy];
[attrs setValue:[UIColor blueColor] forKey:UITextAttributeTextColor];
cell.bubbleView.textView.linkTextAttributes = attrs;
}
}
// Customize any UILabel properties for timestamps or subtitles
if (cell.timestampLabel) {
cell.timestampLabel.textColor = [UIColor lightGrayColor];
cell.timestampLabel.shadowOffset = CGSizeZero;
}
if (cell.subtitleLabel) {
cell.subtitleLabel.textColor = [UIColor lightGrayColor];
}
// Enable data detectors
cell.bubbleView.textView.dataDetectorTypes = UIDataDetectorTypeAll;
}
UIAppearance
[[JSBubbleView appearance] setFont:[UIFont systemFontOfSize:16.0f]];
Customize your message bubbles with JSBubbleImageViewFactory
Customize your avatars with JSAvatarImageFactory
Please follow these sweet contribution guidelines.
Created by @jesse_squires, a programming-motherfucker.
Assets extracted using @0xced / iOS-Artwork-Extractor.
Originally inspired by @soffes / SSMessagingViewController.
Many thanks to the contributors of this project.
Square message bubbles designed by @michaelschultz.
I initially developed this control to use in Hemoglobe for private messages between users.
As it turns out, messaging is a popular thing that iOS devs and users want. Thus, I am supporting this project in my free time and have added features way beyond what Hemoglobe ever needed.
Check out my work at Hexed Bits.
Contact me to have your app listed here.
You are free to use this as you please. No attribution necessary, but much appreciated.
Copyright © 2013 Jesse Squires
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.