日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

IOS客户端Coding项目记录(二)

發(fā)布時(shí)間:2024/4/13 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 IOS客户端Coding项目记录(二) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

9:第三方插件整理

JSON轉(zhuǎn)實(shí)體:jsonModel https://github.com/icanzilb/JSONModel/ 美化按鍵:BButton https://github.com/mattlawer/BButton 狀態(tài)欄提示:JDStatusBarNotification https://github.com/jaydee3/JDStatusBarNotification 照片顯示插件:MJPhotoBrowser https://github.com/azxfire/MJPhotoBrowser 在列表行劃動(dòng)顯示更多選項(xiàng):SWTableViewCell https://github.com/cewendel/swtableviewcell 圖片查看插件:mwphotobrowser https://github.com/mwaterfall/mwphotobrowser 滾動(dòng)條插件:asprogresspopupview https://github.com/alskipp/asprogresspopupview 時(shí)間處理:nsdate-helper https://github.com/billymeltdown/nsdate-helper 各種進(jìn)度條:m13progresssuite https://github.com/marxon13/m13progresssuite 彈出提示mbprogresshud: https://github.com/jdg/mbprogresshud

10:button顯示設(shè)置不同字體

[_headerFansCountBtn setAttributedTitle:[self getStringWithTitle:@"粉絲" andValue:_curUser.fans_count.stringValue] forState:UIControlStateNormal];方法(根據(jù)長(zhǎng)度來設(shè)置其不同的樣式顯示):- (NSMutableAttributedString*)getStringWithTitle:(NSString *)title andValue:(NSString *)value{NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", title, value]];[attriString addAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15],NSForegroundColorAttributeName : [UIColor blackColor]}range:NSMakeRange(0, title.length)];[attriString addAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15],NSForegroundColorAttributeName : [UIColor colorWithHexString:@"0x3bbd79"]}range:NSMakeRange(title.length+1, value.length)];return attriString; }

11:UITableviewcell的accessoryType屬性

cell.accessoryType?=?UITableViewCellAccessoryNone;//cell沒有任何的樣式?? cell.accessoryType?=?UITableViewCellAccessoryDisclosureIndicator;//cell的右邊有一個(gè)小箭頭,距離右邊有十幾像素; cell.accessoryType?=?UITableViewCellAccessoryDetailDisclosureButton;//cell右邊有一個(gè)藍(lán)色的圓形button;? cell.accessoryType?=?UITableViewCellAccessoryCheckmark;//cell右邊的形狀是對(duì)號(hào);?

12:layoutSubviews在以下情況下會(huì)被調(diào)用

a、init初始化不會(huì)觸發(fā)layoutSubviews。 b、addSubview會(huì)觸發(fā)layoutSubviews。 c、設(shè)置view的Frame會(huì)觸發(fā)layoutSubviews,當(dāng)然前提是frame的值設(shè)置前后發(fā)生了變化。 d、滾動(dòng)一個(gè)UIScrollView會(huì)觸發(fā)layoutSubviews。 e、旋轉(zhuǎn)Screen會(huì)觸發(fā)父UIView上的layoutSubviews事件。 f、改變一個(gè)UIView大小的時(shí)候也會(huì)觸發(fā)父UIView上的layoutSubviews事件。 g、直接調(diào)用setLayoutSubviews。

13:導(dǎo)航欄的按鍵(自定義圖片)

UIButton *settingBtn = [self navButtonWithImageName:@"settingBtn_Nav" action:@selector(settingBtnClicked:)];self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:settingBtn];UIButton *addUserBtn = [self navButtonWithImageName:@"addUserBtn_Nav" action:@selector(addUserBtnClicked:)];self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:addUserBtn];

14:自定義表格行(繼承UITableViewCell)

@interface TitleRImageMoreCell () @property (strong, nonatomic) UILabel *titleLabel; @property (strong, nonatomic) UIImageView *userIconView; @end @implementation TitleRImageMoreCell- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];if (self) {// Initialization codeself.accessoryType = UITableViewCellAccessoryDisclosureIndicator;if (!_titleLabel) {_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, ([TitleRImageMoreCell cellHeight] -30)/2, 100, 30)];_titleLabel.backgroundColor = [UIColor clearColor];_titleLabel.font = [UIFont systemFontOfSize:16];_titleLabel.textColor = [UIColor blackColor];[self.contentView addSubview:_titleLabel];}if (!_userIconView) {_userIconView = [[UIImageView alloc] initWithFrame:CGRectMake((kScreen_Width- kTitleRImageMoreCell_HeightIcon)- kPaddingLeftWidth- 30, ([TitleRImageMoreCell cellHeight] -kTitleRImageMoreCell_HeightIcon)/2, kTitleRImageMoreCell_HeightIcon, kTitleRImageMoreCell_HeightIcon)];[_userIconView doCircleFrame];[self.contentView addSubview:_userIconView];}}return self; }- (void)layoutSubviews{[super layoutSubviews];if (!_curUser) {return;}self.titleLabel.text = @"頭像";[self.userIconView sd_setImageWithURL:[_curUser.avatar urlImageWithCodePathResizeToView:_userIconView] placeholderImage:kPlaceholderMonkeyRoundView(_userIconView)]; }+ (CGFloat)cellHeight{return 70.0; }@end然后進(jìn)行調(diào)用時(shí)(可以屬性傳值,并在不同的地方加載不同的行及其高度):- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{if (indexPath.section == 0 && indexPath.row == 0) {TitleRImageMoreCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleRImageMore forIndexPath:indexPath];cell.curUser = _curUser;[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];return cell; } else { TitleValueMoreCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleValueMore forIndexPath:indexPath]; } return cell; }

15:當(dāng)給按鍵的圖標(biāo)進(jìn)行方向改變

[self setImage:[UIImage imageNamed:@"nav_arrow_down"] forState:UIControlStateNormal]; self.imageView.transform = CGAffineTransformRotate(self.imageView.transform, DEGREES_TO_RADIANS(180));//這這是進(jìn)行180度轉(zhuǎn)到,向下或向下

16:在導(dǎo)航欄中間增加一個(gè)帶圖片文字的控件

- (UIDownMenuButton *)initWithTitles:(NSArray *)titleList andDefaultIndex:(NSInteger)index andVC:(UIViewController *)viewcontroller{self = [super init];if (self) {_titleList = titleList;_curIndex = index;_curShowing = NO;_mySuperView = viewcontroller.view;self.backgroundColor = [UIColor clearColor];[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];[self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];[self.titleLabel setFont:[UIFont systemFontOfSize:kNavTitleFontSize]];[self.titleLabel setMinimumScaleFactor:0.5];[self addTarget:self action:@selector(changeShowing) forControlEvents:UIControlEventTouchUpInside];[self refreshSelfUI];}return self; }- (void)refreshSelfUI{NSString *titleStr = @"";DownMenuTitle *menuObj = [self.titleList objectAtIndex:self.curIndex];titleStr = menuObj.titleValue;CGFloat titleWidth = [titleStr getWidthWithFont:self.titleLabel.font constrainedToSize:CGSizeMake(kScreen_Width, 30)];//獲得文字的寬度CGFloat btnWidth = titleWidth +kNavImageWidth;self.frame = CGRectMake((kScreen_Width-btnWidth)/2, (44-30)/2, btnWidth, 30);self.titleEdgeInsets = UIEdgeInsetsMake(0, -kNavImageWidth, 0, kNavImageWidth);self.imageEdgeInsets = UIEdgeInsetsMake(0, titleWidth, 0, -titleWidth);[self setTitle:titleStr forState:UIControlStateNormal];[self setImage:[UIImage imageNamed:@"nav_arrow_down"] forState:UIControlStateNormal]; }其中幾個(gè)值:#define kNavTitleFontSize 19 #define kScreen_Width [UIScreen mainScreen].bounds.size.width #define kNavImageWidth (15.0+5.0)然后直接賦給titleview:UIDownMenuButton *navBtn = [[UIDownMenuButton alloc] initWithTitles:titleList andDefaultIndex:index andVC:self];navBtn.menuIndexChanged = block;self.navigationItem.titleView = navBtn;注意:button都是有帶文字跟圖片的,只是圖片都是在左邊,要通過uiedgeinsetsmake對(duì)圖片跟文字進(jìn)行位置的改變。可以在導(dǎo)航欄的titleview做文章,放一些其它控件,或視圖;

17:集合視圖UICollectionView的簡(jiǎn)單使用

要遵循三個(gè)協(xié)議:UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout設(shè)置單元格的布局 UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init]; [flowLayout setItemSize:CGSizeMake(70, 100)];//設(shè)置cell的尺寸 [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];//設(shè)置其布局方向 flowLayout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);//設(shè)置其邊界 //其布局很有意思,當(dāng)你的cell設(shè)置大小后,一行多少個(gè)cell,由cell的寬度決定 然后設(shè)置集合視圖: _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, 320, self.view.frame.size.height) collectionViewLayout:flowLayout];_collectionView.dataSource = self;_collectionView.delegate = self;_collectionView.backgroundColor = [UIColor clearColor];[_collectionView registerClass:[BMCollectionCell class] forCellWithReuseIdentifier:CELL_ID];[self.view addSubview:_collectionView];注意:其它委托事件沒全寫出,比如numberOfSectionsInCollectionView等;

?

總結(jié)

以上是生活随笔為你收集整理的IOS客户端Coding项目记录(二)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。