1. 初始化NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"YOUR_STRING"];还有一种初始化方法,直接在初始化时给String赋属性值:- (instancetype)initWithString:(NSString *)str attributes:(nullable NSDictionary<NSString *, id> *)attrs; 2. 给String赋属性值例如,把前4位字符字体颜色改为红色:[attributedString addAttribute:NSForegroundColorAttributeName ...
//添加手势,点击屏幕其他区域关闭键盘操作UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(SEL)];gesture.numberOfTapsRequired = 1;gesture.delegate = self;[self.view addGestureRecognizer:gesture];
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{// 若...
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ cell.separatorInset = UIEdgeInsetsZero; cell.layoutMargins = UIEdgeInsetsZero; cell.preservesSuperviewLayoutMargins = NO;}原文:http://www.cnblogs.com/niit-soft-518/p/7404941.html
1int main(int argc, constchar * argv[]) {2 @autoreleasepool {3 Person *p1 = [[Person alloc] initWithName:@"张三"];4 Person *p2 = [[Person alloc] initWithName:@"李四"];5 Person *p3 = [[Person alloc] initWithName:@"王五"];6//3创建一个数组 7 NSArray *array = [[NSArray alloc] initWithObjects:p1,p2,p3, nil];8 NSMutableArray *arraym = [[NSMutableArray alloc] i...
Model 类:@interface ListModel : NSObject@property (nonatomic, copy)NSString *time;
@property (nonatomic, copy)NSString *cname;
@property (nonatomic, copy)NSString *summary;
@property (nonatomic, copy)NSString *title;
@property (nonatomic, copy)NSString *type;- (void)createArray:(NSDictionary *)resultdataSource:(NSMutableArray *)dataSource;VC:#import"ViewController.h"#import"ListModel.h"#import"D...
在他们的定义UItableView什么时候,选择当style至Group时间,后常透明切割线依然,去除。只有再次刷新了BackgroundView它可以覆盖原来的 //取消切割线 UIView *view= [ [ [ UIView
alloc ] init ] autorelease]; [cell setBackgroundView :view]; //取消点击效果 cell.selectionStyle =
UITableViewCellSelectionStyleNone;版权声明:本文博客原创文章。博客,未经同意,不得转载。原文:http://www.cnblogs.com/h...
iOS中表格(UITableView)嵌套表格的简单实现首先说一下思路:我们在一个控制器里面定义2个tableview,一个作为被嵌套的rootTable,一个作为嵌套的表格tableView1,那我们要实现UITableViewDelegate,UITableViewDataSource,的代理的时候,该怎么区分呢?其实很简单,有两种方法,一个是给定义的2个tableview设置tag值,另一个是直接写出来tableView== rootTable时实现他得代理,否则就实现tableView1的代理方法。测试环境 Xcode6.1
Dem...
-(NSArray<UITableViewRowAction*>*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"删除"handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {NSLog(@"删除");}];UITableViewRowAction *rowActionSec = [UITableViewRowA...
最常见的header就是在tableView下拉时header里的图片会放大的那种,最近研究了一下,自己实现了这种header。 1.设置TableView的contentInset(为header预留空间)和contentOffset(使tableView加载完成后显示最顶部)tableView.contentInset = UIEdgeInsetsMake(headerHeight, 0, 0, 0)
tableView.setContentOffset(CGPoint.init(x: 0, y: -headerHeight), animated: true) 2.为header添加约束(SnapKit)var headerHeightConstrain...
今天做公司产品的时候遇到了如题问题,困扰我很长时间,用尽各种办法不能解决,究其原因不知为何,自定义cell低端有view划线的时候,划线一般的显示1像素,而贴着section的显示很少 顶多0.3像素,这个问题很头疼,后来 想到了一个非常好的办法解决: UIImageView *separatorLine = [[UIImageViewalloc] initWithFrame:CGRectMake(20.0f*SizeScaleX,
30*SizeScaleY -
1.0f, cell.frame.size.width,
1.0f)]; separatorLine.image = [[U...
iOS中关于动态Tableview中的cell数据传输的多线程问题解决之拙见(2015-12-05 12:48:20)[编辑][删除]转载▼ 首先我们先明确一下问题:1.因为UI是在主线程中更新的,不能在down数据的同时显示界面,这样会使得下载的时间占用主线程,导致的后果就是你的屏幕就那样的卡死在哪了2.如果要解觉问题1,就势必要将其下载数据的环节放在其他分线程上来实现,但是这里还会遇见一个问题,分线程的执行是不会有序的,这样,在动态显示的过 程中,cell中的...
一、项目文件结构和plist文件 二、实现效果三、代码示例1.没有使用配套的类,而是直接使用xib文件控件tag值操作数据模型部分:YYtg.h文件 1 //2 // YYtg.h3 // 01-团购数据显示(没有配套的类)4 //5 // Created by apple on 14-5-29.6 // Copyright (c) 2014年 itcase. All rights reserved.7 //8 9 #import <Foundation/Foundation.h>
10 #import "Global.h"
11
12 @interface YYtg : NSObject
13 @property(nonatomic,copy...
<DIV style=‘font-family: "Comic Sans MS";‘>学英语。所以用英文来记录笔记。
1:首先实现下单选1:使用一个变量记录选中的行@property (assign, nonatomic) NSIndexPath *selIndex; //单选选中的行2:设置tableView数据,共2组,每组10行,- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2;}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 10;}3:实现tableView的点击方法,每次点击记录点击的索引,取消之前的选择行,将当...
一、一个简单的英雄展示程序NJHero.h文件代码(字典转模型) 1 #import <Foundation/Foundation.h>2 3 @interface NJHero : NSObject4 /**5 * 头像6 */7 @property (nonatomic, copy) NSString *icon;8 /**9 * 名称
10 */
11 @property (nonatomic, copy) NSString *name;
12 /**
13 * 描述
14 */
15 @property (nonatomic, copy) NSString *intro;
16
17 - (instancetype)initWithDict:(NSDictionary *)dict;
18 + (ins...