表情代码
来源:互联网 发布:易语言打开网页源码 编辑:程序博客网 时间:2024/04/28 03:15
/
/
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
表情键盘弹出
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
/
/
UIScrollView
*
faceView
=
[[UIScrollView alloc] initWithFrame
:
CGRectMake
(
0
,
self.
view
.frame.size.height
,
kScreenWidth
,
140
)
];
faceView
=
[[UIView alloc] initWithFrame
:
CGRectMake
(
0
,
self.
view
.frame.size.height
,
kScreenWidth
,
140
)
];
faceView.backgroundColor
=
[UIColor whiteColor];
[self.
view
addSubview
:
faceView];
for
(
int i
=
0
; i
<
40
; i
+
+
)
{
NSString
*
faceStr;
if
(
i
<
10
)
{
faceStr
=
[NSString stringWithFormat
:
@
"[smiley_00%d]"
,
i];
}
else
{
faceStr
=
[NSString stringWithFormat
:
@
"[smiley_0%d]"
,
i];
}
[arrayFace addObject
:
faceStr];
}
/
/
arrayFace
=
[[NSMutableArray alloc] initWithObjects
:
@
"[/smiley_0]"
,
@
"[/smiley_1]"
,
@
"[/smiley_2]"
,
@
"[/smiley_3]"
,
@
"[/smiley_004]"
,
@
"[/smiley_005]"
,
@
"[/smiley_006]"
,
@
"[/smiley_007]"
,
@
"[/smiley_008]"
,
@
"[/smiley_009]"
,
@
"[/smiley_010]"
,
@
"[/smiley_011]"
,
@
"[/smiley_012]"
,
@
"[/smiley_013]"
,
@
"[/smiley_014]"
,
@
"[/smiley_015]"
,
@
"[/smiley_016]"
,
@
"[/smiley_017]"
,
@
"[/smiley_018]"
,
@
"[/smiley_019]"
,
@
"[/smiley_020]"
,
@
"[/smiley_021]"
,
@
"[/smiley_022]"
,
@
"[/smiley_023]"
,
@
"[/smiley_024]"
,
@
"[/smiley_025]"
,
@
"[/smiley_026]"
,
@
"[/smiley_027]"
,
@
"[/smiley_028]"
,
nil];
for
(
int i
=
0
; i
<
arrayFace.count; i
+
+
)
{
NSString
*
imageStr;
if
(
i
<
10
)
{
imageStr
=
[NSString stringWithFormat
:
@
"smiley_00%d"
,
i];
}
else
{
imageStr
=
[NSString stringWithFormat
:
@
"smiley_0%d"
,
i];
}
/
/
NSString
*
imageStr
=
[NSString stringWithFormat
:
@
"smiley_%d"
,
i];
UIButton
*
faceButt
=
[UIButton buttonWithType
:
UIButtonTypeCustom];
[faceButt setFrame
:
CGRectMake
(
10
+
i%
10
*
30
,
i
/
10
*
30
,
20
,
20
)
];
[faceButt setBackgroundImage
:
[UIImage imageNamed
:
imageStr] forState
:
UIControlStateNormal];
[faceButt addTarget
:
self action
:
@selector
(
faceSelect
:
)
forControlEvents
:
UIControlEventTouchUpInside];
faceButt.titleLabel.
text
=
[arrayFace objectAtIndex
:
i];
[faceView addSubview
:
faceButt];
}
#pragma mark - 选中表情获取选中表情信息
-
(
void
)
faceSelect
:
(
UIButton
*
)
sender
{
DLog
(
@
"%@"
,
sender.titleLabel.
text
)
;
faceShow
=
NO;
c%@%@
",contentStr,[NSString stringWithFormat:@"
%@
",sender.titleLabel.text]];
inputText.text = contentStr;
hiddenTF.hidden = YES;
// testView = [[UIView alloc] initWithFrame:CGRectMake(0, 200, kScreenWidth - 2 * 10, 40)];
// testView = [self bubbleView:contentStr];
// [_baseScrollView addSubview:testView];
faceView.hidden = YES;
}
//图文混排
-(void)getImageRange:(NSString*)message : (NSMutableArray*)array {
NSRange range=[message rangeOfString: BEGIN_FLAG];
NSRange range1=[message rangeOfString: END_FLAG];
//判断当前字符串是否还有表情的标志。
if (range.length>0 && range1.length>0)
{
if (range.location > 0)
{
[array addObject:[message substringToIndex:range.location]];
[array addObject:[message substringWithRange:NSMakeRange(range.location, range1.location+1-range.location)]];
NSString *str=[message substringFromIndex:range1.location+1];
// NSString* str = [message substringWithRange:NSMakeRange(range.location, range1.location+1-range.location)];
[self getImageRange:str :array];
}
else
{
NSString *nextstr=[message substringWithRange:NSMakeRange(range.location, range1.location+1-range.location)];
//排除文字是“”的
if (![nextstr isEqualToString:@"
"])
{
[array addObject:nextstr];
NSString *str=[message substringFromIndex:range1.location+1];
[self getImageRange:str :array];
}
else
{
return;
}
}
} else if (message.length > 0)
{
[array addObject:message];
}
}
#pragma mark - 图文混排区域
#define KFacialSizeWidth 20
#define KFacialSizeHeight 20
//#define MAX_WIDTH 150
#define MAX_WIDTH kScreenWidth-2*10
-(UIView *)assembleMessageAtIndex : (NSString *) message
{
NSMutableArray *array = [[NSMutableArray alloc] init];
[self getImageRange:message :array];
UIView *returnView = [[UIView alloc] initWithFrame:CGRectZero];
NSArray *data = array;
UIFont *fon = [UIFont systemFontOfSize:13.0f];
CGFloat upX = 0;
CGFloat upY = 0;
CGFloat X = 0;
CGFloat Y = 0;
if (data) {
for (int i=0;i < [data count];i++) {
NSString *str=[data objectAtIndex:i];
NSLog(@"
add
---str>%@",str);
if
(
[str hasPrefix
:
BEGIN_FLAG]
&
&
[str hasSuffix
:
END_FLAG]
)
{
if
(
upX
>
=
MAX_WIDTH
)
{
upY
=
upY
+
KFacialSizeHeight;
upX
=
0
;
X
=
MAX_WIDTH;
Y
=
upY;
}
NSLog
(
@"
add
----str(image)---->%@",str);
NSString
*
imageName
=
[str substringWithRange
:
NSMakeRange
(
2
,
str.length
-
3
)
];
NSMutableArray
*
arrayTemp
=
[[NSMutableArray alloc] init];
for
(
int i
=
0
; i
<
arrayface.count; i
+
+
)
=
"
" {="
" nsstring="
" *strfaceimage;="
" strfaceimage="
[NSString
" stringwithformat:@"
smiley_%d
",i];="
" [arraytemp="
" addobject:strfaceimage];="
" }="
" bool="
" isexit="
NO;
" for="
" (int="
" z="
0
;
" z<arraytemp.count;="
" z++)="
" nsstring*="
" strtemp="
[arrayTemp
" objectatindex:z];="
" if="
" ([strtemp="
" isequaltostring:imagename])="
" break;="
" (!isexit)="
" j="
0
;
" <="
" [str="
" length];="
" j++)="
" *temp="
[str
" substringwithrange:nsmakerange(j,="
" 1)];="
" (upx="
">= MAX_WIDTH)
{
upY = upY + KFacialSizeHeight;
upX = 0;
X = MAX_WIDTH;
Y =upY;
}
CGSize size=[temp sizeWithFont:fon constrainedToSize:CGSizeMake(150, 40)];
UILabel *la = [[UILabel alloc] initWithFrame:CGRectMake(upX,upY,size.width,size.height)];
la.f>= MAX_WIDTH)
{
upY = upY + KFacialSizeHeight;
upX = 0;
X = MAX_WIDTH;
Y =upY;
}
CGSize size=[temp sizeWithFont:fon constrainedToSize:CGSizeMake(150, 40)];
UILabel *la = [[UILabel alloc] initWithFrame:CGRectMake(upX,upY,size.width,size.height)];
la.f%.1f %.1f"
,
X
,
Y
)
;
DLog
(
@
"在此处调用推送接口"
)
;
return
returnView;
}
-
(
UIView
*
)
bubbleView
:
(
NSString
*
)
text
{
UIView
*
returnView
=
[self assembleMessageAtIndex
:
text
];
return
returnView;
}
<
/
arrayface.count;
>
0 0
- 表情代码
- 魔法表情演示代码
- textView表情代码相关
- Emoji表情代码大全
- 博客回复的表情代码
- java代码过滤emoji表情
- QQ聊天 代码 输入表情
- 表情
- 表情
- 表情
- 表情
- 超酷:MSN表情祝福代码
- QQ空间签到说说表情代码大全
- 表情自动生成器java代码实现
- 在RTF里表情图像与表情代码的互逆
- 微信和qq默认表情代码对照表及表情文件下载
- 代码提交的时候可以插入表情了-GitHub表情的使用
- 泰囧表情的生成器代码,不用PS也能恶搞。
- Slider滑竿+动画
- 二叉搜索树与双向链表
- IntelliJ IDEA的高效快捷键设置
- 第一行代码笔记5(ListView)
- Apache—DBUtils框架简介、DbUtils类、QueryRunner类 、ResultSetHandler接口
- 表情代码
- Linux内核编程初探:块设备驱动程序——Ramdisk
- ADT18.0.0之后jar包(support-v4)管理源码的方法
- apache/iis访问日志转到sql存储的程序思维
- web开发中处理特殊符号(&)随笔
- 软件测试7到9章总结
- ios开发一些零碎的小知识(二)
- [LeetCode] 9.Palindrome Number
- windbg可以查看GDT表