IOS開發基礎知識--片段29,ios基礎知識--29

來源:互聯網
上載者:User

IOS開發基礎知識--片段29,ios基礎知識--29

1:心跳效果,並可去除心跳

- (void)initScaleLayer{    self.view.backgroundColor=[UIColor blueColor];    UIButton *myTelButtom=[[UIButton alloc]initWithFrame: CGRectMake(60, 240, 50, 50)];    UIImage *btnTelImage=[UIImage imageNamed:@"customer_tel_icon"];    [myTelButtom setBackgroundImage:btnTelImage forState:UIControlStateNormal];    [myTelButtom setBackgroundImage:[UIImage imageNamed:@"customer_tel_icon"] forState:UIControlStateHighlighted];    [myTelButtom addTarget:self action:@selector(btnSave:) forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:myTelButtom];        //設定劇本    CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];    scaleAnimation.fromValue = [NSNumber numberWithFloat:1.0];    scaleAnimation.toValue = [NSNumber numberWithFloat:1.2];    scaleAnimation.autoreverses = YES;    scaleAnimation.fillMode = kCAFillModeForwards;    scaleAnimation.repeatCount = MAXFLOAT;    scaleAnimation.duration = 0.8;        //開演    [myTelButtom.layer addAnimation:scaleAnimation forKey:@"scaleAnimation"];}-(void)btnSave:(id)sender{    UIButton *btn=(UIButton *)sender;    [btn.layer removeAnimationForKey:@"scaleAnimation"];    }

 

2:啟動動畫效果實現

原理:啟動頁同樣是放一張靜態圖,只是在啟動時再建立一個圖片視圖把一張跟啟動頁的圖片做動畫;如下:

@interface AppDelegate ()@property (strong,nonatomic) UIImageView *niceView;@end@implementation AppDelegate@synthesize niceView;- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    self.window.rootViewController = [[ViewController alloc]init];;    [self.window makeKeyAndVisible];        //圖片擴大淡出的效果開始;        //設定一個圖片;    niceView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];    niceView.tag=11;    niceView.image = [UIImage imageNamed:@"launch4.7.png"];        //添加到情境    [self.window addSubview:niceView];        //放到最頂層;    [self.window bringSubviewToFront:niceView];        CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];    niceView.layer.anchorPoint = CGPointMake(.5,.5);    animation.fromValue = @1.0f;    animation.toValue = @1.3f;    animation.fillMode=kCAFillModeForwards;            animation.removedOnCompletion = NO;        [animation setAutoreverses:NO];        //動畫時間    animation.duration=0.9;    animation.delegate=self;        [niceView.layer addAnimation:animation forKey:@"scale"];        //結束;        return YES; }-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{    [niceView removeFromSuperview];    }

 

3:計算標籤的寬度並計算是否換行顯示

-(void)creatUI:(NSMutableArray *)tagArr{        self.tagArr = [NSMutableArray arrayWithArray:[tagArr mutableCopy]];        if (self.is_can_addTag) {//如果可以添加標籤,那麼數組就多一個添加標籤按鈕        [self.tagArr addObject:self.addTagStr.length>0?self.addTagStr:@"添加標籤"];    }    tagView_height = 0;        self.backgroundColor = self.tagViewBackgroundColor?self.tagViewBackgroundColor:[UIColor whiteColor];        previousFrame = CGRectZero;        [self.tagArr enumerateObjectsUsingBlock:^(id value, NSUInteger idx, BOOL *stop) {                //Tag標題(看傳入的是字典還是字串)        NSMutableString *titleStr = [NSMutableString stringWithString:self.tagStateType==1?@"  ":@""];        if ([value isKindOfClass:[NSString class]]) {            [titleStr appendString:value];        }else if([value isKindOfClass:[NSDictionary class]]){            if (!self.tagArrkey) {                //擷取不到Value,因為沒傳入Key                NSLog(@"擷取不到Value,因為沒傳入Key");                return ;            }            [titleStr appendString:[value valueForKey:self.tagArrkey]];        }                //建立Label        UILabel*tagLabel = [[UILabel alloc]initWithFrame:CGRectZero];        [self creatTagUI:tagLabel];        tagLabel.text = titleStr;        tagLabel.tag = KTapLabelTag+idx;                //計算label的大小        NSDictionary *attrs = @{NSFontAttributeName : [UIFont systemFontOfSize:self.tagFont?self.tagFont:KTagFont]};        CGSize Size_str = [titleStr sizeWithAttributes:attrs];        Size_str.width += K_Tag_Title_H_Marin*2;        Size_str.height += K_Tag_Title_V_Marin*2;                CGRect newRect = CGRectZero;                if (previousFrame.origin.x + previousFrame.size.width + Size_str.width + K_Tag_Right_Margin > JF_Screen_Width) {                        newRect.origin = CGPointMake(10, previousFrame.origin.y + Size_str.height + K_Tag_Bottom_Margin);            tagView_height += Size_str.height + K_Tag_Bottom_Margin;        }        else {            newRect.origin = CGPointMake(previousFrame.origin.x + previousFrame.size.width + K_Tag_Right_Margin, previousFrame.origin.y);                    }        newRect.size = Size_str;        [tagLabel setFrame:newRect];        previousFrame=tagLabel.frame;                //改變控制項高度        if (idx==self.tagArr.count-1) {            [self setHight:self andHight:tagView_height+Size_str.height + K_Tag_Bottom_Margin];        }        [self addSubview:tagLabel];                        //新增刪除、添加功能        if (self.is_can_addTag&&idx==self.tagArr.count-1) {//能添加狀態&&最後一個-->(進入添加tag介面不用顯示刪除圖片)                    }else{            if (self.tagStateType==1) {                //移除的圖片                UIImageView *removeImage = [[UIImageView alloc] initWithFrame:CGRectMake(tagLabel.jf_right-Image_Width*1.5, tagLabel.jf_top+(tagLabel.jf_height-Image_Height)/2, Image_Width, Image_Height)];                //刪除圖片可以換成自己的圖片                removeImage.image = [UIImage imageNamed:@"btn_removeTag"];                [self addSubview:removeImage];            }        }                        //點擊按鈕        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(tagLabel.frame.origin.x, tagLabel.frame.origin.y, tagLabel.frame.size.width, tagLabel.frame.size.height)];        [button setTag:KButtonTag+idx];        [button addTarget:self action:@selector(clickTag:) forControlEvents:UIControlEventTouchUpInside];        [self addSubview:button];                    }];}

 

4:Fabric增加指令碼KEY的操作內容

把相應的DSYM檔案也上傳到官網;

 

5:通過xcrun atos查看dsym報錯的詳細地址(每次打包時要把當前對應的.DSYM檔案儲存下來,為後期定位錯誤做準備)

進入到DSYM檔案的檔案地方,

使用xcrun atos命令

atos -o YourApp.app.dSYM/Contents/Resources/DWARF/YourApp 0x00062867

執行個體:

從友盟或者其它地方可以獲得報錯的編碼,通過上面的命令就可以查看到錯誤地址;

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.