4000-520-616
欢迎来到免疫在线!(蚂蚁淘生物旗下平台)  请登录 |  免费注册 |  询价篮
主营:原厂直采,平行进口,授权代理(蚂蚁淘为您服务)
咨询热线电话
4000-520-616
当前位置: 首页 > 新闻动态 >
热卖商品
新闻详情
Image and multiline text in an MGLine-开源项目-CSDN问答
来自 : CSDN技术社区 发布时间:2021-03-24

私信 访问主页

\"weixin_39944375\" weixin_39944375 2020-12-02 02:24 首页 开源项目 Image and multiline text in an MGLine

As described here: https://github.com/sobri909/MGBox/issues/14

This shouldn t be too hard to implement. The biggest issue will be what the API should look like. I m imagining something like:

 objc// multiline text on the rightMGLine *row [MGLine lineWithLeft:[UIImage imageNamed: thing ] multilineRight: a long string width:304];// multiline text on the leftMGLine *row [MGLine lineWithMultilineLeft: a long string right:[UIImage imageNamed: thing ] width:304];

And provide properties like thus:

 objcrow.multilineLeft a long string row.multilineRight a long string 

MGLine now also accepts middle items, so perhaps it would make sense to allow multiline text for the centre as well.

该提问来源于开源项目 sobri909/MGBoxKit

点赞 写回答 收藏 复制链接分享 删除 再等等 结题 再想想 8条回答

私信 访问主页

\"weixin_39614750\" weixin_39614750 3月前

Of course not! You re right !! Thanks! Everything works great now! Thank you very much

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39944375\" weixin_39944375 3月前

Your row3 is only 100pt wide. Is that the intended width?

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39614750\" weixin_39614750 3月前

Hi all,I tried to create an layout two rows:-header - with text alignment on center-one row - with three words ( left on the left, middle on the middle and right on the right)

Here is my code:

MGLineStyled *header [MGLineStyled lineWithLeft: Lesson 1 right:nil size:rowSize];header.leftPadding header.rightPadding 16;header.leftItemsTextAlignment NSTextAlignmentCenter;[section.topLines addObject:header];MGLine *row3 [MGLine lineWithLeft:nil multilineRight: asdasd width:100 minHeight:100];row3.multilineLeft left row3.multilineMiddle middle row3.multilineRight right [section.topLines addObject:row3];

However, the alignment is not as I expected. You can see in the picture how it is:

\"Captura

What am I doing wrong?Thanks

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39944375\" weixin_39944375 3月前

Cool! Looks great :) Love the design.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39641231\" weixin_39641231 3月前

Awesome! Thanks man. Will check it out shortly. Your library has played a big role in my app: http://cl.ly/image/0q1M3T3S2z2t

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39944375\" weixin_39944375 3月前

Rightie. This one s done.

The API is as described above, with some extras. Basically it allows you to have multiline labels on the left, middle, or right, and mixed in with other items. So for example multiline text on the left with an image on the right, or multiline text in the middle with an image on the left and another image on the right.

New convenience factory methods:

 objc (id)lineWithMultilineLeft:(NSString *)left right:(id)right width:(CGFloat)width  minHeight:(CGFloat)height; (id)lineWithLeft:(id)left multilineRight:(NSString *)right width:(CGFloat)width  minHeight:(CGFloat)height;

New multiline string properties:

 objc (nonatomic, copy) NSString *multilineLeft; (nonatomic, copy) NSString *multilineMiddle; (nonatomic, copy) NSString *multilineRight;

New height control properties:

 objc (nonatomic, assign) CGFloat minHeight; (nonatomic, assign) CGFloat maxHeight;

And new text alignment properties:

 objc (nonatomic, assign) NSTextAlignment leftItemsTextAlignment; (nonatomic, assign) NSTextAlignment middleItemsTextAlignment; (nonatomic, assign) NSTextAlignment rightItemsTextAlignment;

Also any string that contains a newline char will be considered to be multiline, so you can also do something like this as a shorthand:

 objcMGLine *line [MGLine lineWithLeft: a long string\\n right:nil];

Note that it will be important to pay attention to the line s sidePrecedence, as the default side precedence is left, which means that the left side items will consume as much width as they want, which may leave no room for right or middle items.

So if for example you have an image that you want to appear on the right, you should set the line s sidePrecedence to right, so that the right items get to take up space first, and the remainder is left for left and middle.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39944375\" weixin_39944375 3月前

That actually looks a not too bad way to go about it to me.

The multiline label is added to leftItems, and rightItems is still available to use, there s just no space for it (because the multiline took up all the space). Grab the label, manipulate the label and line to allow for space on the right, then put something in on the right.

It really shouldn t be that hard, but until MGLine allows internally for it, what you ve got there is probably one of the better ways of working around it.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39641231\" weixin_39641231 3月前

For anyone else having this issue right now, I m accomplishing this with:

 objectivec MGLine *line [MGLine multilineWithText:text font:nil width:WIDTH-32 padding:PADDING]; UILabel *label [line.leftItems objectAtIndex:0]; line.size (CGSize){WIDTH, label.size.height 32}; line.sidePrecedence MGSidePrecedenceRight; line.rightItems [arrow].mutableCopy;

Might not be the best way to go about it, but hey, it seems to work.

点赞 评论 复制链接分享 提交 再想想 采纳 为你推荐 如何在Go中编写多行字符串? stringmultiline 9个回答在同一行上打印多行字符串 multilineprinting 2个回答根据文本大小调整图像大小 imagephpgd 2个回答php - 在多行上转换单行字符串,然后插入图像 imagetextphpgdmultiline 2个回答将变量替换为多行shell变量 variablesmultilineshellphpsql 2个回答HTML中的MultiLine表单? htmlmultilineformsphp 3个回答使用Jqplot和ajax的MultiLine Graphics phpjqplotjquery 1个回答如何使用PDO绑定参数方法将多行文本插入mysql? mysqlpdophp 1个回答PHP正则表达式多行字符串的一部分 domregexmultilinephp 1个回答在PHP代码中嵌入多行警报框 javascriptmultilinephp 1个回答PHP和Doxygen具有多个属性声明 propertiesvariable-declarationmultilinephpdoxygen 1个回答PCRE_MULTILINE“m”修饰符 regexnewlinephppcre 1个回答用于php脚本的html中的MultiLine文本框 htmlmultilinetextboxphp 1个回答在 JavaScript 中创建多行字符串 heredocstringjavascriptmultiline 0个回答如何在 Perl 中输入多行注释? [重复] commentsperlmultiline 0个回答中的多行文本 uitextviewiosmultilineline-breaksuilabel 25个回答怎么设置换行的属性?VBCRLF不行的 2个回答怎么用VBCRLF常量来给控件换行? 1个回答关于TextView中文本太长的问题 textviewandroidmultilinexml 3个回答 点击登录 提问题 欢迎建议意见 . 如何写高质量提问和回答? 采纳榜7天 被采纳次数 ProfSnail 25 幻灰龙 19 qq_34124780 154 coagenth 115 规则边缘 116 GoCityPass新加坡曼谷通票 117 cpp_learner 98 Jack_Yang(数据分析及可视化) 99 我不喜欢这个世界 810 天际的海浪 6 加急问题 500 500 基于tensorflow的模型做预测时,cpu占用率过高,如何降低程序的cpu占用率? 100 unity 设置Animation的culling type 导致游戏崩溃 100 java实现下面两个算法 100 ECDSA加密算法中,签名和验证都是需要时间的,那其时间复杂度怎么用椭圆曲线参数如阶或模p来表示呢? 75 数据库只有myd文件没有frm,myi文件,怎么打开呢 51 利用Adams联合matlab仿真求运动学反解问题 50 labview使用datasocket与c/c#程序的通信 50 如何用C语言实现凯撒密码对文本文件(.txt)的读取穷举暴力破解? 50 已知地图GPS坐标点A和坐标点B,获取A点往B点直线走一定距离的坐标点经纬度? 50 用java实现以下算法

本文链接: http://mgline.immuno-online.com/view-692799.html

发布于 : 2021-03-24 阅读(0)
公司介绍
品牌分类
联络我们
服务热线:4000-520-616
(限工作日9:00-18:00)
QQ :1570468124
手机:18915418616