1. 程式人生 > >iOS設定指定文字顏色為紅色

iOS設定指定文字顏色為紅色

//設定 指定內容顯示成紅色
NSString *[email protected]"閱讀並接受《風險披露》宣告";
NSMutableAttributedString *att = [[NSMutableAttributedString alloc]initWithString:title2];
[att addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(5, 6)];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(55, 202, 250, 30)];

label.font = [UIFont systemFontOfSize:15];
label.text = title2;
label.textColor = [UIColor lightGrayColor];
label.attributedText = att; 

相關推薦

iOS設定指定文字顏色紅色

//設定 指定內容顯示成紅色NSString *[email protected]"閱讀並接受《風險披露》宣告";NSMutableAttributedString *att = [[NSMutableAttributedString alloc]initWith

ios 設定狀態列文字顏色白色

直接在程式碼裡面設定是沒有什麼作用的 ,曾經嘗試各種方法,就下面的方法直接簡單理解 第一步:需要將plist 檔案 中加入: <key>UIViewControllerBasedStatusBarAppearance</key> <f

android 適配華透明狀態列 ,保留虛擬導航鍵,設定狀態列透明,且設定狀態列文字顏色黑色

設定後狀態列不遮擋底部contentview裡的內容,但是狀態列上的圖示文字顏色和我的主題色白色混在一起了 public static void setTranslucentKeepVirtualNav(Activity activity) { if (Build.VERSIO

iOS 設定UITabBar,背景顏色,預設圖片,文字顏色,和選中顏色.

  對於UITabBar設定背景顏色很簡單,backbackgroundColor不要使用,即使設定了也不起作用,應該使用barTintColor設定背景.    那麼圖示和文字的預設顏色怎麼設定呢

iOS文字設定樣式,插入圖片,設定指定文字的點選事件

富文字:NSMutableAttributedString 它與普通文字之間最大的區別是可以設定不同欄位範圍的字型,顏色, 大小,樣式等. 字型大小 NSMutableAttributedString *attributed = [[NSMutableAttribut

android設定狀態列顏色深色

public boolean setDeepStatusBar(boolean isChange,Activity mActivity) { if (!isChange){ return false; } if(Build.VERSI

MyEclipse中設定JSP文字顏色

        MyEclipse背景設定成黑色的之後,新建JSP檔案後,那句文字資訊 This is my JSP page.就會看不到了,因為這段字也是黑色,就算是在首選項中設定JSP的各種style,都無濟於事,這個時候就應該去設定html的style,當你把html

Android之TextView設定String文字顏色

每一次我們在textview佈局的時候,當遇到多個文字顏色的時候,會變得很麻煩,這時候是需要一個textview,設定一個textcolor 還是有其他更好的辦法呢?下面我們來看看有幾種能設定textview 顏色:

修改PagerSlidingTabStrip實現新增圓角,設定選中文字顏色

最近使用到PagerSlidingTabStrip但是不符合需求就直接稍微改了下,增加了設定橫線圓角,和設定選中文字顏色,以及根據文字大小橫線變化長度.能用到的朋友可以使用/* * Copyright (C) 2013 Andreas Stuetz <[email&#

iOS 設定指定的檢視圓角

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:cell.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBott

ios設定TextField游標顏色

今天遇到個奇怪的問題,textField不知何時消失了?其實是變成白色了,設定textField的背景色就可以看出來,至於為什麼會這樣還沒找到原因 只能設定游標顏色 1、[textField setValue:[UIColor redColor] forKeyPath:@"

iOS 設定UIActionSheet 按鈕顏色

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {     for (UIView *view in actionSheet.subviews) {         if (view.tag == 1

iOS設定tabBar背景顏色

viewDidLoad中設定//設定tabBar的顏色    UIView *bgView = [[UIViewalloc] initWithFrame:self.tabBar.bounds];    bgView.backgroundColor = [UIColorblue

iOS 設定View任意角圓角

通過程式碼設定UIView的任意一個角為圓角 先建立RectCorner 繼承自UIView   .h程式碼 #import <UIKit/UIKit.h> @interface RectCorner : UIView /**  * 頂部圓角

iOS 上利用 fallback 機制不同語言的文字 (script) 設定字型,從而使得文字混排更為優雅

如果您是一位 WEB 開發者,相信您對 CSS 的 font-family 屬性一定不會陌生。通常我們會為 font-family 屬性設定一長串的字型(家族)列表,就像這樣的: .text { font-family: Menlo, Monaco, Consolas, "Courier

Android 關於TextView中,設定指定部分文字改變顏色,和指定部分文字點選事件

參考文章 我想要實現的是如下這樣的效果 首先要想實現文字變色以及點選,都需要使用到SpannableStringBuilder,例項化該類也很簡單,只需將你想要處理的字串當做引數 Span

iOS改變Label上指定文字顏色

UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 100, 20)]; textLabel

iOS StatusBar狀態欄文字顏色更改

sel tro 所有 ani 更新 statusbar isa rst ear 1、將單個頁面的StatusBar文字顏色改為白色,動態更改也可以在這裏設置 -(UIStatusBarStyle)preferredStatusBarStyle { return U

iOS設定主題顏色方便使用

在AppDelegate.h檔案中宣告一個全域性變數: @property UIColor *zhuTiColor; 在AppDelegate.m中,新增:@synthesize zhuTiColor; 然後在 (BOOL)application:(UIApp

筆記-iOS設定圓角方法以及指定位置設圓角

第一種方法:通過設定layer的屬性 程式碼: UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"TestImage"]]; // 只需設定layer層的兩個屬性 // 設定圓角 imageVi