1,UIButton里面的字体和图片左对齐

button.imageEdgeInsets = UIEdgeInsetsMake(0,180/2,0.0,320/2)

let btnRect = button.titleRectForContentRect(button.bounds)

let width = button.frame.size.width - 180/2 - image!.size.width*4

button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, width - 10 - btnRect.size.width);

2, 将两个Label 转换成一个:

原:

viewY = viewY + 100/2

viewHeight = 60/2

var friendInviteLabel = UILabel()

friendInviteLabel.frame = CGRectMake(viewX,viewY, viewWidth,viewHeight)

friendInviteLabel.backgroundColor = UIColor.clearColor()

friendInviteLabel.textAlignment = NSTextAlignment.Center

friendInviteLabel.font =  UIFont.systemFontOfSize(38/2)

friendInviteLabel.textColor = DefaultTabBarColor

friendInviteLabel.text = Str_label_invite_friends

self.addSubview(friendInviteLabel)

viewY = viewY + viewHeight

viewHeight = 48/2

var  friendInviteBonusLabel  = UILabel()

friendInviteBonusLabel.frame=CGRectMake(viewX,viewY, viewWidth,viewHeight)

friendInviteBonusLabel.backgroundColor = UIColor.clearColor()

friendInviteBonusLabel.textAlignment = NSTextAlignment.Center

friendInviteBonusLabel.font = UIFont.systemFontOfSize(26/2)

friendInviteBonusLabel.textColor = COLORWITHRGB(11,179,125)

friendInviteBonusLabel.text = Str_label_invite_bonus

self.addSubview(friendInviteBonusLabel)

之后  :

viewY = viewY + 60/2

viewHeight = 60/2 + 48/2

var friendInviteLabel = UILabel()

friendInviteLabel.frame = CGRectMake(viewX,viewY, viewWidth,viewHeight)

var strlength = Str_label_invite_friends.length

var bounsStrLength = Str_label_invite_bonus.length

// let str =  Str_label_invite_friends + "\n"  + Str_label_invite_bonus

var inviteStr:NSMutableAttributedString = NSMutableAttributedString(string:Str_label_invite_friends, attributes:[NSForegroundColorAttributeName:DefaultTabBarColor,NSFontAttributeName:UIFont.systemFontOfSize(38/2)])

inviteStr.addAttribute(NSForegroundColorAttributeName, value: UIColor(red: 11.0/255, green: 179.0/255, blue: 125.0/255, alpha: 1.0) , range: NSMakeRange( strlength - bounsStrLength  , bounsStrLength))

inviteStr.addAttribute(NSFontAttributeName, value: UIFont.systemFontOfSize(28/2), range:  NSMakeRange(strlength - bounsStrLength ,bounsStrLength))

friendInviteLabel.attributedText = inviteStr

friendInviteLabel.backgroundColor = UIColor.clearColor()

friendInviteLabel.textAlignment = NSTextAlignment.Center

friendInviteLabel.numberOfLines = 0

self.addSubview(friendInviteLabel)

3, navigationBar 添加背景

var imageView:UIImageView = UIImageView(frame:CGRect(x:0 ,y: -20,width: xWidth,height: CustomNavbarHeight-20))

imageView.image = UIImage(named: "action bar_bg.png")

self.navigationController!.navigationBar.addSubview(imageView)

swift + jj实践的更多相关文章

  1. 17条 Swift 最佳实践规范

    本文由CocoaChina译者小袋子(博客)翻译自schwa的github主页原文作者:schwa 这是一篇 Swift 软件开发的最佳实践教程. 前言 这篇文章是我根据在 SwiftGraphics ...

  2. 【同行说技术】swift最全学习资料汇集(一)

    Swift,苹果于2014年WWDC(苹果开发者大会)发布的新开发语言,可与Objective-C*共同运行于Mac OS和iOS平台,用于搭建基于苹果平台的应用程序.2015年12月4日,苹果公司宣 ...

  3. FIR.im Weekly - 这是多产的一周

    前方干货颇多,请备好小板凳,泡好茶,慢慢看. 上周四到周六(23号-25号),由 infoQ 主办的 QCon 在北京召开,各技术大牛围绕敏捷开发.技术架构.开发实践等话题进行了技术分享与探讨. QC ...

  4. 参加2012 Openstack亚太技术大会

    参加2012 OpenStack亚太技术大会 OpenStack是一个由Rackspace发起.全球开发者共同参与的开源项目,旨在打造易于部署.功能丰富且易于扩展的云计算平台.OpenStack企图成 ...

  5. Swift 编程语言自己实践 -自己在Xcode6 动手写20140603

    Swift 是什么,大家都回去百度或者Google,有的甚至认为是Taylor Swift(她是我的偶像),但是如果今天在百度百科里搜索绝对没有说是Apple最新推出的编程语言,因为是在2014年6月 ...

  6. swift 实践- 08 -- UISegmentedControl

    import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoa ...

  7. Swift 实践之UIWebView

    1.选中工程,点击右键,New File>在iOS下选中Othe>Empty,生成一个.js的脚本文件,将代码粘贴过去保存; var script = document.createEle ...

  8. Swift ios应用开发实践

  9. swift 实践- 14 -- UIScrollView

    import UIKit class ViewController: UIViewController ,UIScrollViewDelegate{ override func viewDidLoad ...

随机推荐

  1. struts自定义拦截器

    第01步:配置web.xml,启动struts框架 <?xml version="1.0" encoding="UTF-8"?> <web-a ...

  2. C#与js的各种交互

    今天遇到一个问题,查到不错的资料,放上来记录一下,以防忘记地址,算是我的笔记吧! 很多人都向在服务器端调用客户端的函数来操作,也就是在asp中调用javascript脚本中已经定义好的脚本函数.经过研 ...

  3. sdf

    SDF(Standard Delay Format)是一种存储timing data的文件,其中的数据是tool-independent的 可以包括: 1)Delay: module path, de ...

  4. ajax中网页传输(三)XML——下拉列表显示练习

    XML:页面之间传递数据,跨平台传递 HTML:超文本标记语言,核心标签 XML的形势为 <xml version='1.0'> <Nation> <one> &l ...

  5. linux下调整音量大小

    不得不说,在linux下整音频和视频真是不容易.在windows中自带了关于音频和视频的工具,在linux下要两眼一抹黑地使用命令进行操作. 主要还是在linux下没找到合适的gui的调整工具. 几番 ...

  6. [slim] Slim - Faster, lightweight, a enginer for Ruby

    URL: http://slim-lang.com/ Example: doctype html html head title Slim Examples meta name="keywo ...

  7. 三层架构和MVC模式

    目录[-] 1.三层架构 2.MVC 2.1 标准的MVC(Model-View-Controller) 2.2 Web MVC 3.三层架构和MVC的区别与联系 1.三层架构 三层架构(3-tier ...

  8. linux设备驱动归纳总结(六):3.中断的上半部和下半部——tasklet【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-100005.html linux设备驱动归纳总结(六):3.中断的上半部和下半部——tasklet x ...

  9. React笔记_(7)_react路由

    路由 路由(routing)是指分组从源到目的地时,决定端到端路径的网络范围的进程. 路由器当然是作为一个转发设备出现的,主要是转发数据包来实现网络互联. 那么react的路由到底指的是什么呢? 举个 ...

  10. 安装LAMP

    1.首先打开命令行,获得最新的软件包 sudo apt-get install update 2.安装MySQL数据库 sudo apt-get install mysql-server mysql- ...