簡體   English   中英

帶動畫的ios簡單條形圖

[英]ios simple bar graph with animation

我需要在我的應用程序中顯示2個條形圖,我不想使用核心情節,因為過度殺傷只顯示2個變量高度的條形圖,[UIimageView with box.png]

我只是使用UIView動畫完成了一些測試,這似乎足以使條形成長或縮小,[問題是高度取決於起點,所以我的條形對Y沒有0點,哪里有變化與酒吧的高度]

那我怎么能為我的Y軸設置一個0點?所以我只需要考慮高度,而不是起點?

或者我應該使用一些不像核心情節那樣過度殺死的條形發生器框架,

什么是最簡單,最輕的重量?

電積

ecgraph ,其他?

PS。 另一點是,我需要有一個自定義的圖表背景,自定義欄,這就是為什么我使用box.png為條]

編碼...

viewDidLoad { ***
CGRect chartbackGroundImageRect = CGRectMake(150, 20, 632, 653);
UIImageView *chartbackGroundImage = [[UIImageView alloc] initWithFrame:chartbackGroundImageRect];
[chartbackGroundImage setImage:[UIImage imageNamed:@"chartArtBgnd.png"]];
chartbackGroundImage.opaque = YES; // explicitly opaque for performance
[self.view addSubview:chartbackGroundImage];
[chartbackGroundImage release];
CGRect leftBarImageRect = CGRectMake(550, 550, 81, 40);
leftBarImage = [[UIImageView alloc] initWithFrame:leftBarImageRect];
[leftBarImage setImage:[UIImage imageNamed:@"leftBar.png"]];
leftBarImage.opaque = YES; // explicitly opaque for performance
[self.view addSubview:leftBarImage];
[leftBarImage release];
***}

testBarAnimation {*** 
 // Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2]; //animation for arrow
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationBeginsFromCurrentState:YES];

CGRect newFrame = CGRectMake(550, 300, 81, 290);

leftBarImage.frame = newFrame;


[UIView commitAnimations];
***}

非常感謝!

我不知道,它適用於您的項目。 但是我使用了不同的方法,因為iOS沒有適合Chart的好庫。

我使用UIWebview與Web上提供的基於HTML5 / CSS的免費圖表引擎。 對我來說它的工作正常,比本機圖表慢一點對我的項目來說足夠了

定義效用函數:

CGRect modifyRectByHeight(CGRect originalRect, CGFloat newHeight)
{
    CGRect result = originalRect;

    result.origin.y += height;
    result.size.height += height;

    return result;
}

然后使用如下:

leftBarImage.frame = modifyRectByHeight( leftBarImage.frame, 150);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM