uilabel

UILabel Background Color Leaks to Border

一曲冷凌霜 提交于 2020-04-09 04:52:22
问题 I'm creating a UILabel to which I set the background color and corner radius with the following code: self.scoreLabel.backgroundColor = [UIColor DISRed];// custom red` self.scoreLabel.layer.masksToBounds = YES; self.scoreLabel.layer.cornerRadius = self.scoreLabel.frame.size.width/2; self.scoreLabel.layer.borderWidth = 8.0; self.scoreLabel.layer.borderColor = [[UIColor DISNavy] CGColor]; However the background's color seems to be leaking to the edge of the border (see image). Any ideas why?

UILabel Background Color Leaks to Border

有些话、适合烂在心里 提交于 2020-04-09 04:49:10
问题 I'm creating a UILabel to which I set the background color and corner radius with the following code: self.scoreLabel.backgroundColor = [UIColor DISRed];// custom red` self.scoreLabel.layer.masksToBounds = YES; self.scoreLabel.layer.cornerRadius = self.scoreLabel.frame.size.width/2; self.scoreLabel.layer.borderWidth = 8.0; self.scoreLabel.layer.borderColor = [[UIColor DISNavy] CGColor]; However the background's color seems to be leaking to the edge of the border (see image). Any ideas why?

Can't reset UILabel attributedText when a UITableViewCell is reused

你离开我真会死。 提交于 2020-03-17 11:47:47
问题 The problem I'm using a UITableView to show the list of transactions of a credit card. If the transaction is a chargeback, I'm adding a strikethrough style to the label: The problem happens when that specific cell is reused. The strikethrought decoration is still there, even after resetting the text and attributedText property of the label. Below I've added the relevant parts of my code: Table view class TimelineViewController: UIViewController { private lazy var tableView: UITableView = {

Add UIGestureRecognizer to individual letters of UILabel

て烟熏妆下的殇ゞ 提交于 2020-03-05 03:39:33
问题 Right Now I am making an iOS app and I would like to implement the ability to remove letters in a UILabel by simply "Dropping the letter". The part That I am having an issue with is adding a gesture recognizer to individual letters of a UILabel. I have already searched the web for this and have nothing.Just to be clear, I am NOT adding a gesture recognizer to the whole label, I am only wanting to add it to individual letters. Any help is greatly appreciated. Thanks 回答1: It seems that the

IOS 为UILabel添加长按复制功能

浪子不回头ぞ 提交于 2020-03-04 01:18:43
IOS 为UILabel添加长按复制功能 在iOS中下面三个控件,自身就有复制-粘贴的功能: 1、UITextView 2、UITextField 3、UIWebView UIKit framework提供了几个类和协议方便我们在自己的应用程序中实现剪贴板的功能。 1、UIPasteboard:我们可以向其中写入数据,也可以读取数据 2、UIMenuController:显示一个快捷菜单,用来展示复制、剪贴、粘贴等选择的项。 3、UIResponder中的 canPerformAction:withSender:用于控制哪些命令显示在快捷菜单中。 4、当快捷菜单上的命令点击的时候,UIResponderStandardEditActions将会被调用。 下面这些项能被放置到剪贴板中 1、UIPasteboardTypeListString — 字符串数组, 包含kUTTypeUTF8PlainText 2、UIPasteboardTypeListURL — URL数组,包含kUTTypeURL 3、UIPasteboardTypeListImage — 图形数组, 包含kUTTypePNG 和kUTTypeJPEG 4、UIPasteboardTypeListColor — 颜色数组 剪贴板的类型分为两种: 系统级

iOS项目之模拟请求数据

浪子不回头ぞ 提交于 2020-02-26 12:38:53
如何在iOS开发中更好的做假数据? 当工期比较紧的时候,项目开发中会经常出现移动端等待后端接口数据的情形,不但耽误项目进度,更让人有种无奈的绝望。所以在开发中,我们常常自己做些假数据,以方便开发和UI调试。然而做假数据方法不同,效率和安全性都各不同,有时稍有不慎,还会产生很大的bug。因此本文拟结合我在贝聊的开发经验,讲一讲我们组在iOS开发中曾经用过的做假数据的方法及其优劣。 示例项目 为方便下文的说明,本文主要以贝聊家长版app发现首页的热门帖子列表的实现为例。热门帖子列表的样式如下图: 这是比较常见的列表,用常用的 UITableView 实现即可,但需要自定义一个的 UITableViewCell 的子类 ExploreTableViewCell 。项目中, ExploreTableViewCell 并没有用xib实现(因为xib日后不好修改,且代码复用性差),而是通过 SnapKit 用纯代码布的局,具体的布局代码大致如下: 123456789101112131415161718192021222324252627282930313233343536 import UIKitimport SnapKitclass ExploreTableViewCell: UITableViewCell { let thumbnailImageView: UIImageView let

Displaying NSMutableAttributedString on iOS 8

*爱你&永不变心* 提交于 2020-02-13 04:36:43
问题 Seems on iOS 8.0 (12A365) NSMutableAttributedString sometimes will not be displayed correctly. The problem obviously occurs when the range of the attribute does not start at the beginning of the text (and if there is no other attribute starting at the beginning of the text). So with 1.) the second word "green" in will not show the green background (bug!) ("cell" is a UITableViewCell with UILabel "label" as a subview): 1.) text = [[NSMutableAttributedString alloc] initWithString:@"Green is

Displaying NSMutableAttributedString on iOS 8

给你一囗甜甜゛ 提交于 2020-02-13 04:36:10
问题 Seems on iOS 8.0 (12A365) NSMutableAttributedString sometimes will not be displayed correctly. The problem obviously occurs when the range of the attribute does not start at the beginning of the text (and if there is no other attribute starting at the beginning of the text). So with 1.) the second word "green" in will not show the green background (bug!) ("cell" is a UITableViewCell with UILabel "label" as a subview): 1.) text = [[NSMutableAttributedString alloc] initWithString:@"Green is

UIButton ------ UIEdgeInsets属性

纵饮孤独 提交于 2020-02-03 04:22:35
UIButton共有三种属性 1.contentEdgeInsets 2.titleEdgeInsets 3.imageEdgeInsets UIEdgeInsets 先来看看内部代码是怎样写的 typedef struct __attribute__ ( ( objc_boxable ) ) UIEdgeInsets { CGFloat top , left , bottom , right ; } UIEdgeInsets ; 原来是结构体,它的四个参数:top, left, bottom, right, 分别表示距离上边界,左边界,下边界,右边界的位移,默认值均为0。 contentEdgeInsets 我们都知道,UIButton按钮可以只设置一个UILabel或者一个UIImageView,还可以同时具有UILabel和UIImageView;如果给按钮设置contentEdgeInsets属性,就是按钮的内容整体(包含UILabel和UIImageView)进行偏移 按钮内容整体向右下分别移动10像素: button . contentEdgeInsets = UIEdgeInsetsMake ( 10 , 10 , - 10 , - 10 ) ; titleEdgeInsets & imageEdgeInsets 这两个属性的效果是相辅相成的

UILabel render text incorrectly in IOS7

不羁岁月 提交于 2020-01-31 12:31:05
问题 I use following code to calculate the bound of a UILabel CGRect bound = [lblName.text boundingRectWithSize:(CGSize){206, 99999} options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:stringAttributes context:nil]; The UILabel is a embedded in a UIScrollView , which is a subview of UITableViewCell . here what i got I made a test which use a UILabel in a table cell, and a UILabel in UIScrollView separately, and results are as I expected Note that all setting