【代码笔记】浮点数管理并去掉多余的0,代码笔记浮点数

一,代码。

威尼斯城真人赌钱网站 1

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    NSLog(@"--float-%@-",[self stringDisposeWithFloat:9.000899990000]);

}
#pragma -mark -functions
//浮点数处理并去掉多余的0
-(NSString *)stringDisposeWithFloat:(float)floatValue
{
    NSString *str = [NSString stringWithFormat:@"%f",floatValue];
    long len = str.length;
    for (int i = 0; i < len; i++)
    {
        if (![str  hasSuffix:@"0"])
            break;
        else
            str = [str substringToIndex:[str length]-1];
    }
    if ([str hasSuffix:@"."])//避免像2.0000这样的被解析成2.
    {
        //s.substring(0, len - i - 1);
        return [str substringToIndex:[str length]-1];
    }
    else
    {
        return str;
    }
}

威尼斯城真人赌钱网站 2

 

二,输出。

2015-10-16 09:53:45.765 浮点数处理并去掉多余的0[1554:47555] --float-9.0009-
2015-10-16 09:53:48.824 浮点数处理并去掉多余的0[1554:47619] Terminating since there is no system app.

 

一,代码。 – (void)viewDidLoad{ [super viewDidLoad]; // Do any
additional setup after loading the…

浮点数管理并去掉多余的0,浮点数

代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    NSLog(@"--float-%@-",[self stringDisposeWithFloat:9.000899990000]);

}
//浮点数处理并去掉多余的0
-(NSString *)stringDisposeWithFloat:(float)floatValue
{
    NSString *str = [NSString stringWithFormat:@"%f",floatValue];
    int len = str.length;
    for (int i = 0; i < len; i++)
    {
        if (![str  hasSuffix:@"0"])
            break;
        else
            str = [str substringToIndex:[str length]-1];
    }
    if ([str hasSuffix:@"."])//避免像2.0000这样的被解析成2.
    {
        return [str substringToIndex:[str length]-1];//s.substring(0, len - i - 1);
    }
    else
    {
        return str;
    }
}

输出:

2014-12-02 17:01:08.253 浮点数管理并去掉多余的0[21460:60b]
–float-9.0009-

代码: – ( void
)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after
loading the view. NSLog( @” –float-%@- ” ,[se…

浮点数管理并去掉多余的0,浮点数

代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

     NSLog(@"--float-%@-",[self stringDisposeWithFloat:9.000899990000]);

}
//浮点数处理并去掉多余的0
-(NSString *)stringDisposeWithFloat:(float)floatValue
{
    NSString *str = [NSString stringWithFormat:@"%f",floatValue];
    long len = str.length;
    for (int i = 0; i < len; i++)
    {
        if (![str  hasSuffix:@"0"])
            break;
        else
            str = [str substringToIndex:[str length]-1];
    }
    if ([str hasSuffix:@"."])//避免像2.0000这样的被解析成2.
    {
        return [str substringToIndex:[str length]-1];//s.substring(0, len - i - 1);
    }
    else
    {
        return str;
    }
}

 

代码: – ( void
)viewDidLoad { [super viewDidLoad]; // Do any additional setup after
loading the view, typically from a nib. NSLog…

【代码笔记】伸缩式动画,代码笔记伸缩

一,效果图。

威尼斯城真人赌钱网站 3

二,代码。

威尼斯城真人赌钱网站 4

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [email protected]"伸缩式动画";
}
//点击任何处,弹出动画
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

    UIView *zanView = [[UIView alloc] initWithFrame:CGRectMake(50, 100, 100, 100)];
    zanView.backgroundColor = [UIColor redColor];
    [self.view addSubview:zanView];

    [UIView animateWithDuration:0.3 animations:^{
        zanView.transform = CGAffineTransformMakeScale(1.2, 1.2);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.3 animations:^{
            zanView.transform = CGAffineTransformMakeScale(0.9, 0.9);
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:0.3 animations:^{
                zanView.transform = CGAffineTransformMakeScale(1.0, 1.0);
            } completion:^(BOOL finished) {

            }];
        }];
    }];

}

威尼斯城真人赌钱网站 5

 

 

   

一,效果图。
二,代码。 – (void)viewDidLoad{ [super viewDidLoad]; // Do any
additional setup after loading the vie…

【代码笔记】竖排文字,代码笔记

一,代码。

威尼斯城真人赌钱网站 6

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.


    NSString *str = @"你好啊";
    NSMutableArray *arr = [[NSMutableArray alloc] init];
    for (int i = 0; i<str.length ; i++) {
        NSString *str1 = [str substringWithRange:NSMakeRange(i, 1)];
        NSString *str2 = [str1 stringByAppendingString:@"\n"];

        [arr addObject:str2];
    }
    NSString *str3;
    for (int i = 0; i<arr.count - 1; i++) {
        if (i == 0) {
            str3 = [arr[i] stringByAppendingString:arr[i+1]];
        }else{
            str3 = [str3 stringByAppendingString:arr[i+1]];
        }
    }
    NSLog(@"%@",str3);

}

威尼斯城真人赌钱网站 7

 

二,输出。

2015-10-20 14:25:43.161 竖排文字[8130:197228] 你
好

 

 

   

一,代码。 –
(void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup
after loading the view. NSString *str = @”你好啊…

相关文章