Uiunderlinedbutton.h代码

  1. @interface UIUnderlinedButton : UIButton {
  2. }
  3. + (UIUnderlinedButton *) underlinedButton;
  4. @end

Uiunderlinedbutton.m代码

  1. @implementation UIUnderlinedButton
  2. + (UIUnderlinedButton*) underlinedButton {
  3. UIUnderlinedButton* button = [[UIUnderlinedButton alloc] init];
  4. return [button autorelease];
  5. }
  6. - (void) drawRect:(CGRect)rect {
  7. CGRect textRect = self.titleLabel.frame;
  8. // need to put the line at top of descenders (negative value)
  9. CGFloat descender = self.titleLabel.font.descender;
  10. CGContextRef contextRef = UIGraphicsGetCurrentContext();
  11. // set to same colour as text
  12. CGContextSetStrokeColorWithColor(contextRef, self.titleLabel.textColor.CGColor);
  13. CGContextMoveToPoint(contextRef, textRect.origin.x, textRect.origin.y + textRect.size.height + descender);
  14. CGContextAddLineToPoint(contextRef, textRect.origin.x + textRect.size.width, textRect.origin.y + textRect.size.height + descender);
  15. CGContextClosePath(contextRef);
  16. CGContextDrawPath(contextRef, kCGPathStroke);
  17. }
  18. @end

iOS开发:自定义带下划线文本的UIButton的更多相关文章

  1. 自定义带下划线文本的UIButton

    转载自 http://mobile.51cto.com/hot-404798.htm,略有改动 UnderLineButton.h代码 @interface UnderLineButton : UIB ...

  2. IOS开发之带格式的文本

    有时可能会遇到这样的问题,一个label中设置的文本含有2种以上不同的格式,又不能把它拆解为两个label来显示,这时用NSMutableAttributedString可以很好的解决问题. 示例如下 ...

  3. iOS学习-创建带下划线的button

    UIButton *tempBtn = [UIButton buttonWithType: UIButtonTypeCustom]; tempBtn.frame = CGRectMake(, , , ...

  4. TabTopUnderLineLayout【自定义顶部选项卡(带下划线)】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 自定义顶部选项卡布局LinearLayout类,实现带下划线样式的效果. 备注:如果配合Fragment的话,MainActivit ...

  5. TabTopAutoLayout【自定义顶部选项卡区域(带下划线)(动态选项卡数据且可滑动)】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 自定义顶部选项卡布局LinearLayout类,实现带下划线且可滑动效果.[实际情况中建议使用RecyclerView] 备注:如果 ...

  6. FragmentTabHostUnderLineDemo【FragmentTabHost带下划线】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 使用FragmentTabHost实现顶部选项卡(带下划线效果)展现. 效果图 代码分析 1.该Demo中采用的是FragmentT ...

  7. delphi 仅带下划线的TEdit控件

    在做录入框的时候,很希望有一个只带下划线的文本框,网上介绍的很多,有自己做组件的,须不知Delphi下只需要简单设置几个属性即可达到目的.

  8. 带下划线的 HTTP Header无法获取到可能是因为nginx

    背景:新版本修改了个功能是在老版本的基础上做的,同一个接口,需要兼容老版本,因此让前台在header中封装了 version版本号,client_type 客户端类型,根据这两个字段判断接口要走的逻辑 ...

  9. 关于python中带下划线的变量和函数 的意义

    总结: 变量: 1.  前带_的变量:  标明是一个私有变量, 只用于标明, 外部类还是可以访问到这个变量 2.  前带两个_ ,后带两个_ 的变量:  标明是内置变量, 3.  大写加下划线的变量: ...

随机推荐

  1. 牛客网小白月赛6H(最小生成树【克鲁斯卡尔】)

    #include<bits/stdc++.h>using namespace std;long long sum=0;struct node{    int a,b,len;}road[5 ...

  2. 机房重构——泛型和“DataTable”

    前言 我们都知道在机房重构的时候,大多数都在用七层进行重构,每一层都依赖实体.所以不管怎么调用,返回的应该是实体参数,这样才符合大多数的逻辑,这样我们试想一下,如果我们要求在U层返回多个实体值,怎么办 ...

  3. DataGridView控件对Column的设置

    http://stackoverflow.com/questions/18666582/datagridview-autofit-and-fill 1.Column覆盖所有width: dgv.Aut ...

  4. 基础篇 - pg_isready

    pg_isready 发起一个到指定 PostgreSQL数据库的连接检查. 使用方法: pg_isready [选项]... 选项: -d, --dbname=DBNAME 数据库名 -q, --q ...

  5. 帝都Day3——各种dp

    备注:Day1 Day2记得笔记太233,所以就不发了 备注2:Day4~Day7发不发看心情qaq (7.17持续更新中...) 动态规划A 记忆化搜索 & 动态规划初步 8点15: 杨姓d ...

  6. springMvc json 参数

    以前,一直以为在SpringMVC环境中,@RequestBody接收的是一个Json对象,一直在调试代码都没有成功,后来发现,其实 @RequestBody接收的是一个Json对象的字符串,而不是一 ...

  7. FileTest

    package com.yd.wmsc.util; import java.io.File; public class FileTest { public static void main(Strin ...

  8. 非关系型数据库---Memcached

    一.概述 1.Memcached是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库的负载: 2.Memcached通过 在内存中缓存对象和数据 来减少读取数据库的次数,从而提升网站的 ...

  9. 006 ZigZag Conversion

    The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like ...

  10. bzoj 3732: Network 树上两点边权最值

    http://www.lydsy.com/JudgeOnline/problem.php?id=3732 首先想到,要使得最长边最短,应该尽量走最短的边,在MST上. 然后像LCA那样倍增娶个最大值 ...