One of my app using Charts library for drawing graphs.
Everything works fine but in BarChartView it's adding some default margin around the chart and I have done the below changes in the Chart property but still, it's not removing the margin around the graph.
I have also checked the same issue on this Question thread but no luck at all.
Check below screenshot for margin issue:
I have done the below changes for removing the margin around BarChart.
_barChartView.minOffset = 0;
_barChartView.xAxis.enabled = NO;
ChartYAxis *leftAxis = _barChartView.leftAxis;
leftAxis.drawGridLinesEnabled = NO;
_barChartView.leftAxis.enabled = NO;
_barChartView.leftAxis.drawAxisLineEnabled = NO;
_barChartView.rightAxis.enabled = NO;
_barChartView.rightAxis.drawAxisLineEnabled = NO;
_barChartView.legend.enabled = NO;
But still, I am not able to remove the margin.
Also checked Charts Demo app has the same issue while changing data from the slider.
Check Below screenshot from Chart Demo App:
Any help or hint appreciated :)
Hello I have checked in the demo of Charts library which you have provided.
Where i have added below code and it's work, check the screenshot below.
BarChartViewController.h
Add this code on line number : 115
_chartView.minOffset = 0;
_chartView.xAxis.enabled = NO;
_chartView.leftAxis.enabled = NO;
_chartView.leftAxis.drawAxisLineEnabled = NO;
_chartView.rightAxis.enabled = NO;
_chartView.rightAxis.drawAxisLineEnabled = NO;
_chartView.legend.enabled = NO;
let me know for more.
Here is the output of my simulator with blue background.
I know this is old but just for anyone who stumbles upon the question
This solved it for me
barChartView.leftAxis.axisMinimum = 0
barChartView.rightAxis.axisMinimum = 0
Related
I am using JSQMessageViewController and I am facing the issue (only in ios14) that i cant see media items like Images, Video and Audio in device though these views are generating debug view hierarchy. See below attached image:-
debug view hierarchy screenshot:
here is the description of UIImage inside collection view cell:
<UIImageView: 0x7fe7d6d95b30; frame = (20 8; 177 131); clipsToBounds = YES; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x600001ce4ec0>>
here is the screenshot attached of screen:
You can see the view has generated space for image, but its not showing up!
Is anyone facing this issue? how can i solve this problem. This issue is occurring in iOS 14, it works perfectly in iOS 13.
You need to overwrite in JSQMessagesMediaViewBubbleImageMasker.m
method - (void)jsq_maskView:(UIView *)view withImage:(UIImage *)image and change line:
view.layer.mask = imageViewMask.layer;
to be
view.maskView = imageViewMask;
I suggest you to use category for that. For me that was solution.
I would like to suggest to change like as follows along with the Vladimir answer for backward compatibility:
if (#available(iOS 14.0, *)) {
view.maskView = imageViewMask;
} else {
view.layer.mask = imageViewMask.layer;
}
I want insert space left and right to prevent value label prevent yAxis value. And remove background line under charts.
How can I do?
Edit
self.lineChart.delegate = self;
self.lineChart.descriptionText = #"";
self.lineChart.drawGridBackgroundEnabled = NO;
self.lineChart.scaleXEnabled = NO;
self.lineChart.scaleYEnabled = NO;
self.lineChart.leftAxis.spaceTop = 0.30f;
On Charts 3.0 you can use...
lineChartView.xAxis.spaceMin = 0.2
lineChartView.xAxis.spaceMax = 0.2
...to add some space on left and right.
To remove the background line under the charts use below code :
_lineChart.yAxis.drawGridLinesEnabled = NO;
_lineChart.xAxis.drawGridLinesEnabled = NO;
To add spacing - you can use Charts 3.0, and adjust xAxis.axisMinimum/xAxis.axisMaximum.
To adjust the background, simply use the UIView's properties of backgroundColor, opaque etc.
To disable the grid - adjust the drawGridLinesEnabled on the axes, as #ashmi123 said.
how do we subclass a UIbutton and customize it so that it has a round end like this one on Periscope. The Following Button.
I would like to PREVENT using layer.CornerRadius though.
Using a BezierPath perhaps? but I have a math problem creating the Path.
Any thoughts? Thank you
I have created that button using the layer.CornerRadius as below :-
self.buyButton.layer.cornerRadius = self.buyButton.frame.size.height/2;
self.buyButton.clipsToBounds = YES;
[UPDATED CODE - FOR SHADOW]
self.buyButton.layer.masksToBounds = NO;
self.buyButton.layer.borderWidth = 1.0f; //Just for look n feel
self.buyButton.layer.shadowColor = [UIColor greenColor].CGColor;
self.buyButton.layer.shadowOpacity = 0.8;
self.buyButton.layer.shadowRadius = 12;
self.buyButton.layer.shadowOffset = CGSizeMake(12.0f, 12.0f);
But why u don't want to use the method already provided as per your custom requirement I don't think you need to use bezier path for this.
UPDATED SCREENSHOT :
I have a button in my ios project which displays edit profile if the user is the current user and follow if the user is not the current user.
I am setting the titleLabel text programmatically dependant on the above condition. I am also programatically setting the button text to align center.
The problem I'm having is it works perfectly for the edit profile button which appears as it should center aligned but when showing the follow button the word follow is slightly off center to the left and I can't figure out where I'm going wrong.
Here is my code:
if([userID isEqualToString:credentialID]){
self.followEditBtn.layer.cornerRadius = 2;
self.followEditBtn.layer.borderColor = UIColorFromRGB(0xA6B9C1).CGColor;
self.followEditBtn.layer.borderWidth = 1.0f;
self.followEditBtn.layer.backgroundColor = UIColorFromRGB(0xF8FBFC).CGColor;
self.followEditBtn.titleLabel.textColor = UIColorFromRGB(0xA1B1C3);
self.followEditBtn.titleLabel.text = #"Edit Profile";
self.followEditBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
} else {
self.followEditBtn.layer.cornerRadius = 2;
self.followEditBtn.layer.borderColor = UIColorFromRGB(0x19A548).CGColor;
self.followEditBtn.layer.borderWidth = 1.0f;
self.followEditBtn.layer.backgroundColor = [UIColor whiteColor].CGColor;
self.followEditBtn.titleLabel.textColor = UIColorFromRGB(0x19A548);
self.followEditBtn.titleLabel.text = #"Follow";
self.followEditBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
}
And some images of the buttons as you can see the follow text is slightly off center to the left yet the edit profile button is correctly aligned:
I couldn't reproduce your problem (iOS 6.1 to 7.1). Although I had to make a small change in order to make it work, since it wasn't showing any text.
Instead of using:
self.followEditBtn.titleLabel.text = #"Edit Profile";
you should use:
[self.followEditBtn setTitle:#"Follow" forState:UIControlStateNormal];
I'm assuming you're using a UIButtonTypeCustom type UIButton, and having a fixed frame size.
I'd like you to tell me where are you putting this code, and how is this button being initialized.
I'm writing a UI for iPad and part of that UI needs progress bars for certain parts. However, I'm finding that configuring the UIProgressView is proving difficult. One of the requirements is that the endpoints of the progress view be square, however, I am unable to configure this via the layer's corner radius property:
fProgressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
fProgressView.layer.borderColor = [UIColor whiteColor].CGColor;
fProgressView.progress = 0.5f;
fProgressView.progressImage = nil;
fProgressView.trackImage = nil;
fProgressView.trackTintColor = self.fPatientListPanelColor;
fProgressView.progressTintColor = [UIColor whiteColor];
[fProgressView.layer setCornerRadius:1.0f];
[self.view addSubView:fProgressView]
I find I am also unable to control the height of it. Any thoughts on how to overcome these issues?
There is apparently no way to do this, so I ended up rolling my own version.